GH#2955: Replace blanket 2>/dev/null with explicit file checks in shell-env.sh#3003
Conversation
…nv.sh Address quality-debt from PR #2937 review feedback (GH#2955). Replace all remaining grep 2>/dev/null patterns with either: - Removal (when file existence is already guaranteed by prior logic) - Explicit [[ -f ]] guards (when the file may not exist) This prevents masking permission errors and other non-file-not-found failures while maintaining correct behaviour for missing files.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness and clarity of shell scripts by replacing generic error suppression with more explicit and context-aware file existence checks. The changes ensure that potential issues like permission errors are not silently ignored, leading to more reliable script execution and easier debugging. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Mar 6 16:30:39 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request does a great job of systematically replacing blanket 2>/dev/null error suppression with more explicit file existence checks in setup-modules/shell-env.sh. This is a valuable improvement that prevents masking potential issues like permission errors while correctly handling expected cases like missing files. The changes are logical and well-documented in the PR description. The suggested pattern for grep -c was not included as it could lead to issues with arithmetic expansion when grep -c finds no matches, printing '0' and exiting with status 1, which would then be concatenated with the '0' from || echo 0. This conflicts with the robustness principles for arithmetic operations outlined in Rule 2, which advocates for using parameter expansion (e.g., ${var:-0}) to handle potentially empty or unexpected command substitution results.



Summary
grep ... 2>/dev/nullpatterns insetup-modules/shell-env.shwith explicit[[ -f ]]file existence guards or removes the suppression where file existence is already guaranteed by prior logicChanges (8 locations)
2>/dev/nullbash_filesarray built from[[ -f ]]checks2>/dev/null$zsh_rcexistence verified by early return2>/dev/nullbash_files2>/dev/null[[ -f "$rc_file" ]]guardget_all_shell_rcsmay return non-existent paths on Linux[[ -f "$fish_config" ]]guard2>/dev/null2>/dev/null[[ -f "$rc_file" ]]guard2>/dev/null$tabby_configexistence checked at line 800Verification
2>/dev/nullusages are legitimate (platform command availability, intentional launchctl suppression)Closes #2955