concept
Dry-run mode
Application-defined option that previews planned changes without performing them. It does not guarantee later success; validate arguments and require explicit application for mutation.
Formal Syntax & Structure
bash syntaxbash
--dry-runReturn Value
application-defined status
Application-defined option that previews planned changes without performing them. It does not guarantee later success; validate arguments and require explicit application for mutation.
Working Example
Example Snippetbash
report() { if (( $# != 1 )); then return 2; fi case $1 in --dry-run) printf 'would create report.txt\n' ;; --apply) if (set -C; printf 'ready\n' > report.txt); then printf 'created report.txt\n' else return 1; fi ;; *) printf 'invalid usage\n' >&2; return 2 ;; esac}report --dry-run[[ ! -e report.txt ]] || exit 1report --apply || exit 1cat report.txt