Fix bash crash: replace post-increment with assignment to satisfy set -e#43
Fix bash crash: replace post-increment with assignment to satisfy set -e#43sgumil wants to merge 2 commits intoProducdevity:masterfrom
Conversation
WalkthroughA one-line whitespace normalization was made in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
patch.sh (2)
137-146: Fix is correct: avoidsset -eexit-status trap from((count++)).
count=$((count + 1))will not return exit code 1 whencountwas 0, soset -ewon’t incorrectly abort the script.Consider also making
targetalocal(currently implicitly global within the script) to avoid accidental cross-function reuse:- while IFS= read -r file; do - target="$WORK_DIR/decompiled/$file" + while IFS= read -r file; do + local target="$WORK_DIR/decompiled/$file" if [ -e "$target" ]; then rm -rf "$target" count=$((count + 1)) fi done < "$PATCHES_DIR/files_to_delete.txt"
186-197: Increment change is good; minor scoping polish available.
count=$((count + 1))is the right fix underset -e.Small cleanup to prevent leaking values across functions: declare
rel_path,target,target_diraslocalinside the loop.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
patch.sh(3 hunks)
🔇 Additional comments (1)
patch.sh (1)
154-174: Counter increments nowset -esafe; patch result handling unchanged.Both
count=$((count + 1))andfailed=$((failed + 1))eliminate the non-obvious nonzero status behavior of((var++))underset -e, while preserving the same counter semantics.
Hi, I fixed a crash occurring in patch.sh while running on systems with strict POSIX compliance or specific bash versions.
The issue: The script uses set -e. When using the post increment operator ((count++)) on a variable initialized to 0, bash returns an exit code of 1 because the expression evaluates to 0. This triggers set -e and causes the script to exit immediately.
The fix: I replaced the increment ((count++)) with a standard assignment count=$((count+1)) which removes the ambiguity and avoids false positive error exit code.
Tested and working on Arch Linux.
Closes #51.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.