Results for “working tree”
Small, practical examples. Search by task or narrow things down below.
Calculate with integer arithmetic
Bash Scripts: Calculate with integer arithmetic with a small standalone Bash program.
Bash Scripts✓ Tested
Capture a command’s output
Bash Scripts: Capture a command’s output with a small standalone Bash program.
Bash Scripts✓ Tested
Capture output while handling a failed command
Bash Scripts: An assignment inherits the status of its command substitution, allowing both output and status to be handled.
Bash Scripts✓ Tested
Capture standard output and standard error separately
Bash Scripts: Use distinct redirections when diagnostic text should not be mixed with data.
Bash Scripts✓ Tested
Check a script’s syntax without executing its body
Bash Scripts: bash -n parses commands but does not run ordinary script statements.
Bash Scripts✓ Tested
Check exact array membership
Bash Scripts: Compare each element literally instead of searching a concatenated string.
Bash Scripts✓ Tested
Check for an installed command
Bash Scripts: command -v checks command resolution without assuming a specific installation path.
Bash Scripts✓ Tested
Check that a file is present and nonempty
Test file content availability before reading it.
file check✓ Tested
Check what kind of Git object a revision names
Git: cat-file -t distinguishes a commit, tree, blob, or annotated tag.
Git✓ Tested
Check whether a function has been defined
Bash Scripts: declare -F tests a function name without executing it.
Bash Scripts✓ Tested
Check whether a variable exists under nounset
Bash Scripts: The plus expansion distinguishes an unset variable without reading its missing value.
Bash Scripts✓ Tested
Check whether input is a nonnegative integer
Reject empty input and nonnumeric characters before arithmetic.
validation✓ Tested