Fix: Standardize Syntax and Error Handling#22
Merged
Conversation
- Updated all error/warning messages from 'echo' to 'echo >&2' - Ensures proper separation of output streams - Maintains clean stdout for pipeline processing - Follows shell scripting best practices for error handling
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request addresses SonarCloud code quality alarms by standardizing shell script syntax patterns and improving error handling consistency. The changes implement industry best practices for conditional testing and proper output stream separation across the codebase.
Changes Implemented:
Conditional Test Standardization: Updated conditional tests from
[to[[operator in:src/github/gh-repo-list.sh: GitHub repository listing operationssrc/gitnap/gn-init-git.sh: Git initialization utilitiesError Stream Redirection: Enhanced error handling in:
src/utils/endpoints.sh: API endpoint configuration utilitiesecho >&2for proper stderr redirectionTechnical Details:
1. Conditional Test Operator Standardization
Before (POSIX
[operator):After (Bash
[[built-in):Benefits of
[[Operator:=~), logical operators2. Error Stream Separation
Before (stdout pollution):
After (proper stderr):
Benefits of stderr redirection:
SonarCloud Compliance:
Addressed Rules:
S7688: "Use
[[ ... ]]instead of[ ... ]for conditional tests"[[construct is a bash built-in that provides more features and safer string handling than the POSIX[command. It prevents word splitting and pathname expansion issues.S7677: "Error messages should be sent to stderr"
Quality Impact:
Motivation:
These changes address fundamental shell scripting best practices that directly impact script reliability and maintainability:
[[operator is recommended for all bash scripts as it provides safer and more feature-rich conditional testingThe updates align with industry standards from:
Reference
Testing & Validation:
All modified scripts have been validated to ensure:
[[operatorThese improvements enhance the codebase's quality foundation while maintaining backward compatibility and operational reliability.