Understand the concept
An unquoted expanded Bash variable can undergo word splitting and pathname expansion. A path containing spaces stops being one argument. Double quotes normally preserve the value as one argument while allowing variable expansion. Values beginning with a hyphen may be interpreted as options; use end-of-options where supported.
Apply and decide
By default, a pipeline’s status is the last command’s status. pipefail changes the aggregate result but neither undoes effects nor replaces explicit error handling. set -e has contextual exceptions; do not treat it as proof of correctness. Record what failed and define what can safely be repeated.
Workplace application
In an export script, preserve arguments containing spaces and handle hyphen-leading values according to the command interface. Capture the relevant status before another command replaces it. With pipefail, an intermediate failure can reach the scheduler, but partial files, publication, and retries still need handling. Exercising success, failure, and recovery in a controlled environment reveals differences that one successful execution does not show.
In Bash, printf "%s\n" "$file" preserves spaces in the value. A failed export followed by successful tee may appear successful if only the final status is observed.
Common pitfalls
Assuming quotes validate paths, tee propagates every failure, or pipefail undoes writes.
Related topics: Maintenance and demonstrated recovery · Start with context and preserve evidence
Quoting and exit codes are part of a script’s operating contract.
Reference: bash(1): shell expansion and pipelines · DR Linux 2026.4; networking and Bash manuals reviewed 2026-10-01; cgroup v2 and upstream systemd manuals reviewed 2026-10-01; RHEL 10 examples; Linux man-pages 6.19; OpenSSL 3.5