FIND YOUR NEXT FEW LINES

Results for “Arguments & decisions”

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

35 snippets foundClear filters
Bash ScriptsFunctions & arguments

Give a function an optional argument

Let callers omit a value while keeping nounset enabled.

optional argument✓ Tested
Bash ScriptsFunctions & arguments

Handle an expected command failure

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

exit status✓ Tested
Bash ScriptsFunctions & arguments

Look up values in an associative array

Use named keys for a small in-memory configuration table.

dictionary✓ Tested
Bash ScriptsLoops & decisions

Loop over an array safely

Preserve spaces in array elements while iterating.

array✓ Tested
Docker / ComposeCompose service options

Override the image entrypoint in Compose

Docker / Compose: entrypoint and command combine as executable and arguments.

Docker / Compose✓ Tested
C++Tasks & synchronization

Pass an argument into a worker thread

C++: Thread arguments are copied by default; std::ref explicitly passes a reference.

C++✓ Tested
Bash ScriptsLoops & decisions

Read a file without losing its last line

Handle spaces, backslashes, and a final line without a newline.

read lines✓ Tested
Docker / ComposeImage management

Read an image’s default command

Docker / Compose: Config.Cmd contains the command arguments stored in the image.

Docker / Compose✓ Tested
Bash ScriptsFunctions & arguments

Return text from a shell function

Capture a function’s output with command substitution.

function✓ Tested
Bash ScriptsLoops & decisions

Sum a range of integers

Use an arithmetic loop without launching external processes.

arithmetic✓ Tested
TypeScriptTypes & functions

Type a function’s inputs and output

Catch mismatched arguments during compilation.

function✓ Tested