Results for “fold”
Small, practical examples. Search by task or narrow things down below.
Detect an error inside a pipeline
Use pipefail to observe failure before the last pipeline command.
pipefail✓ Tested
Detect invalid UTF-8 data
Detect invalid UTF-8 data in a complete Rust program using the standard library.
Rust✓ Tested
Disable networking for a Compose command
Docker / Compose: Disable networking for a Compose command in a small Compose file.
Docker / Compose✓ Tested
Dispatch a command with case
Choose an action from a small set of supported commands.
case✓ Tested
Display a fallback for missing data
SQLite: Return a supplied label when a column contains NULL.
SQLite✓ Tested
Display an instant at a fixed offset
Display an instant at a fixed offset using a complete Go program with explicit sample inputs.
Go✓ Tested
Distinguish a bare repository from a working checkout
Git: rev-parse reports repository mode without relying on directory naming conventions.
Git✓ Tested
Distinguish an empty input line from end of input
Bash Scripts: A successful read can return an empty value; its status indicates whether a line was read.
Bash Scripts✓ Tested
Distinguish end-of-input from other errors
Distinguish end-of-input from other errors using a complete Go program with explicit sample inputs.
Go✓ Tested
Distinguish missing keys from zero values
Distinguish missing keys from zero values using a complete Go program with explicit sample inputs.
Go✓ Tested
Distinguish row count from non-null value count
SQLite: COUNT(*) includes every row while COUNT(column) skips NULL values.
SQLite✓ Tested
Distinguish unset variables from empty strings
Bash Scripts: Omitting the colon tests only whether a variable is unset; including it also treats an empty value as missing.
Bash Scripts✓ Tested