Fixing shell script robustness iteratively
You ask an AI for a Bash script to 'rename all the log files to add a date prefix.' It writes a loop with `for f in $(ls *.log)` and `mv $f 2024-...-$f`. It runs fine on your test dir, so you point it at production logs and it mangles a dozen filenames containing spaces and a couple starting with `-`. You tell it 'handle spaces' and it wraps a few vars in quotes but the dash-prefixed files still break. How do you re-steer to get this robust?
plan_log_renames(filenames: list[str], date_prefix: str) → list[str][["app.log","my server.log","-rf.log","notes.txt"],"2024-06-01"]out["mv -- 'app.log' '2024-06-01-app.log'","mv -- 'my server.log' '2024-06-01-my server.log'","mv -- '-rf.log' '2024-06-01--rf.log'","skip:not_a_log"][["it's.log","*.log"],"2024-06-01"]out["mv -- 'it'\\''s.log' '2024-06-01-it'\\''s.log'","mv -- '*.log' '2024-06-01-*.log'"][["a.log","2024-06-01-a.log"],"2024-06-01"]out["error:collision","skip:already_prefixed"]Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.