A script builds `OPTS="--delete --exclude=.git"` and runs `rsync "$OPTS" src/ dst/`. rsync fails with `rsync: --delete --exclude=.git: unknown option`.
AdvancedTroubleshootingTroubleshooting: quoting, expansion and tool-input bugs
Answer
Likely causes → Quoting the string passes all options as one argument. Removing the quotes "works" until an option value contains a space or a glob, then it breaks differently.
Diagnose → printf '[%s]\n' "$OPTS" shows a single argument.
Fix → Use an array, which keeps each option as a separate, intact argument:
opts=(--archive --delete --exclude='.git' --exclude='node_modules')
[[ $dry_run == 1 ]] && opts+=(--dry-run)
rsync "${opts[@]}" src/ dst/
Prevent → Never store command arguments in a plain string; arrays exist for exactly this.
More on Troubleshooting: quoting, expansion and tool-input bugs
`bash: [: too many arguments`Beginner`bash: [: =: unary operator expected`BeginnerA disk check fails with `[: 93%: integer expression expected`Beginner`rm $file` fails with `rm: cannot remove 'monthly': No such file or directory` and `rm: cannot remove 'report.csv'`.BeginnerA cleanup script logs `cp: cannot stat '/var/log/app/*.log': No such file or directory` on quiet days.Beginner`echo "start" > $logfile` fails with `bash: $logfile: ambiguous redirect`Intermediate