FIND YOUR NEXT FEW LINES

Results for “exit status”

Small, practical examples. Search by task or narrow things down below.

52 snippets foundClear filters
Linux CommandsGetting Started

Branch on a command’s exit status

Linux Commands: Branch on a command’s exit status using GNU/Linux commands in an empty practice directory.

Linux Commands✓ Tested
PowerShellCommands & execution context

Check an external process exit status explicitly

PowerShell: LASTEXITCODE reports a native child exit code independently of ordinary PowerShell cmdlet errors.

PowerShell✓ Tested
Bash ScriptsProcesses & environment

Preserve a failure status while an EXIT trap runs

Bash Scripts: Capture the status immediately on entry to the trap before running cleanup commands.

Bash Scripts✓ Tested
Bash ScriptsFunction scope & composition

Use a function’s exit status as a boolean result

Bash Scripts: Return zero for success and test the function directly in a conditional.

Bash Scripts✓ Tested
Bash ScriptsFunctions & arguments

Handle an expected command failure

Branch on a command’s exit code without aborting the script.

exit status✓ Tested
Bash ScriptsText parsing & arithmetic

Increment a counter without an unexpected errexit

Bash Scripts: An assignment avoids the zero-result exit status of a standalone arithmetic post-increment.

Bash Scripts✓ Tested
GitInspecting the working tree

Test whether tracked working files changed

Git: A quiet diff returns status one for differences, so handle it in a conditional.

Git✓ Tested
Bash ScriptsFiles & reliability

Detect an error inside a pipeline

Use pipefail to observe failure before the last pipeline command.

pipefail✓ Tested
PythonFunctions & error handling

Handle an expected child-process failure

Python: Catch CalledProcessError when check=True reports a nonzero exit status.

Python✓ Tested
Bash ScriptsFunctions & arguments

Return text from a shell function

Capture a function’s output with command substitution.

function✓ Tested
GitBranches & ancestry

Test whether one revision is an ancestor of another

Git: merge-base --is-ancestor reports its answer through the exit status.

Git✓ Tested
ReactAccessibility & events

Announce a status update politely

Announce a status update politely with a small React component and explicit browser behavior.

React✓ Tested