Will It Vibe logoWill It Vibe?
SHELL-012Low severity-4 points

'cd' with no error handling

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

If cd fails (a typo, a directory that was never created, a missing mount), every command after it keeps running in the ORIGINAL directory instead of stopping. When that is followed by a broad operation like a build or a cleanup step, it runs against the wrong location. This only fires when the script also has no set -e to catch the failure some other way; chain with && / || (or add set -e) to make the failure fatal.

Why it matters

If cd fails, for example a typo in the path, a directory that was never created, a network mount that isn't up yet, every command written after it keeps running in whatever directory the script was already in, not the one the author assumed. Chained with a broad operation like a build, an rm -rf, or a git command, that means the operation runs in the wrong place while looking like it worked. This rule only fires when the script also has no 'set -e' to catch the failure some other way.

How to fix it

Chain a real check onto every cd: cd "$DIR" || exit 1 (or || return 1 inside a function) so a failed cd stops the script immediately instead of silently continuing elsewhere. Adding set -euo pipefail near the top of the script achieves the same thing for every cd (and every other command) at once.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks