Interview Prep/Shell Scripting/Troubleshooting: quoting, expansion and tool-input bugs

`bash: [: too many arguments`

BeginnerTroubleshootingTroubleshooting: quoting, expansion and tool-input bugs
Answer

Likely causes → An unquoted variable inside [ ] contains spaces or glob characters and expands to several words: [ $status = "active" ] with status="not found". Also happens with [ -f $file ] when $file matches multiple files via globbing.

Diagnose → bash -x shows the expanded test, e.g. + '[' not found = active ']'.

Fix → Quote: [ "$status" = active ], or use [[ $status == active ]].

Prevent → Quote every expansion; ShellCheck SC2086.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: quoting, expansion and tool-input bugs