FIND YOUR NEXT FEW LINES

Results for “exit”

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

23 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

Handle a nonzero background-job exit

Bash Scripts: Wait reports a child’s exit code; put it in a conditional when failure is expected.

Bash Scripts✓ 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
Docker / ComposeGetting Started

Inspect a completed container’s exit code

Docker / Compose: Inspect a completed container’s exit code using a locally available Ubuntu image.

Docker / Compose✓ Tested
Docker / ComposeContainer lifecycle

Inspect the exit code of a completed process

Docker / Compose: Container state retains the exit code until the container is removed.

Docker / Compose✓ 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
Docker / ComposeContainer lifecycle

Wait for a container to exit

Docker / Compose: wait blocks until the container stops and prints its exit code.

Docker / Compose✓ Tested
Bash ScriptsFunctions & arguments

Handle an expected command failure

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

exit status✓ 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

Clean up a temporary directory automatically

Use an EXIT trap so temporary files are removed when the script ends.

mktemp✓ Tested