FIND YOUR NEXT FEW LINES

Results for “Arguments & decisions”

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

35 snippets foundClear filters
Docker / ComposeDockerfile patterns

Keep exec-form arguments literal

Docker / Compose: JSON exec form does not expand shell environment variables.

Docker / Compose✓ Tested
PythonFunctions & error handling

Preconfigure some function arguments

Python: Use partial to produce a callable with selected arguments already bound.

Python✓ Tested
Linux CommandsGetting Started

Print separate arguments safely

Linux Commands: Print separate arguments safely using GNU/Linux commands in an empty practice directory.

Linux Commands✓ Tested
Docker / ComposeGetting Started

Separate an executable from default arguments

Docker / Compose: Separate an executable from default arguments with a complete introductory Dockerfile.

Docker / Compose✓ Tested
Bash ScriptsFunction scope & composition

Give a function its own positional parameters

Bash Scripts: A function receives its call arguments without replacing the caller’s positional parameters.

Bash Scripts✓ Tested
Bash ScriptsFunctions & arguments

Parse a short option with getopts

Read a named option and handle invalid flags explicitly.

getopts✓ Tested
Bash ScriptsGetting Started

Read positional parameters in a function

Bash Scripts: Read positional parameters in a function with a small standalone Bash program.

Bash Scripts✓ Tested
PythonFunctions & error handling

Cache repeated pure function calls

Python: Use lru_cache to avoid recomputing results for identical hashable arguments.

Python✓ Tested
Bash ScriptsLoops & decisions

Check whether input is a nonnegative integer

Reject empty input and nonnumeric characters before arithmetic.

validation✓ Tested
Bash ScriptsLoops & decisions

Dispatch a command with case

Choose an action from a small set of supported commands.

case✓ Tested
jQueryCollections & styling

Find an element’s position among siblings

jQuery: index without arguments reports a zero-based sibling position.

jQuery✓ Tested
Bash ScriptsText parsing & arithmetic

Format a numeric label with leading zeroes

Bash Scripts: Use a constant printf format string and supply values as separate arguments.

Bash Scripts✓ Tested