Fix SC2010 shellcheck errors: replace ls | grep with find#570
Open
Fix SC2010 shellcheck errors: replace ls | grep with find#570
Conversation
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.
Summary
This PR fixes all 5 occurrences of SC2010 shellcheck errors by replacing
ls | greppatterns withfindcommands.What Changed
Files Modified
.github/workflows/pr-build.yml(lines 60-61): Removed SC2010 from ignore list.github/workflows/validate-e2e-tests-are-accounted-for.yml(lines 31, 39, 47, 55, 63): Replacedls | grepwithfindBefore/After Code Snippets
Line 34 (ADOT Java):
Line 42 (ADOT JavaScript):
Line 50 (ADOT Python):
Line 58 (ADOT .NET):
Line 66 (CloudWatch Agent):
Why This Change is Safe
The
findcommand produces identical output to thels | greppipeline:The key difference is that
findis more robust for filenames with special characters (spaces, newlines, etc.), though in this case all workflow files follow standard naming conventions.Testing
Actionlint Validation
actionlint -color -ignore SC2086 -ignore SC2004 -ignore SC2129 -ignore SC2016 -ignore SC2015 -ignore SC2260 -ignore SC2046 -ignore SC2181 .github/workflows/*.ymlExit code: 0 ✓
Behavioral Equivalence Tests
All 5 patterns were tested to ensure identical output between old and new implementations:
Test 1: Java pattern
ls | grep -E '(^java-)|(^metric-limiter-)' | grep -Ev '(lambda-layer-perf-test|otlp-ocb)' | grep -E 'test\.ya?ml$' | sortfind . -maxdepth 1 \( -name 'java-*test.yml' -o -name 'java-*test.yaml' -o -name 'metric-limiter-*test.yml' -o -name 'metric-limiter-*test.yaml' \) ! -name '*lambda-layer-perf-test*' ! -name '*otlp-ocb*' | sed 's|^\./||' | sortTest 2: Node pattern
ls | grep -E '^node-' | grep -v 'lambda-layer-perf-test' | grep -E 'test\.ya?ml$' | sortfind . -maxdepth 1 \( -name 'node-*test.yml' -o -name 'node-*test.yaml' \) ! -name '*lambda-layer-perf-test*' | sed 's|^\./||' | sortTest 3: Python pattern
ls | grep -E '^python-' | grep -v 'lambda-layer-perf-test' | grep -E 'test\.ya?ml$' | sortfind . -maxdepth 1 \( -name 'python-*test.yml' -o -name 'python-*test.yaml' \) ! -name '*lambda-layer-perf-test*' | sed 's|^\./||' | sortTest 4: .NET pattern
ls | grep -E '^dotnet-' | grep -v 'lambda-layer-perf-test' | grep -E 'test\.ya?ml$' | sortfind . -maxdepth 1 \( -name 'dotnet-*test.yml' -o -name 'dotnet-*test.yaml' \) ! -name '*lambda-layer-perf-test*' | sed 's|^\./||' | sortTest 5: CloudWatch Agent pattern
ls | grep -E '(^java-)|(^node-)|(^python-)|(^dotnet-)|(^metric-limiter-)' | grep -Ev '(sigv4|lambda-test|lambda-layer-perf-test|ocb|genesis)' | grep -E 'test\.ya?ml$' | sortfind . -maxdepth 1 \( -name 'java-*test.yml' -o -name 'java-*test.yaml' -o -name 'node-*test.yml' -o -name 'node-*test.yaml' -o -name 'python-*test.yml' -o -name 'python-*test.yaml' -o -name 'dotnet-*test.yml' -o -name 'dotnet-*test.yaml' -o -name 'metric-limiter-*test.yml' -o -name 'metric-limiter-*test.yaml' \) ! -name '*sigv4*' ! -name '*lambda-test*' ! -name '*lambda-layer-perf-test*' ! -name '*ocb*' ! -name '*genesis*' | sed 's|^\./||' | sortImpact Assessment
Type: Code quality improvement
Impact: This is a code quality fix with no functional changes. The shellcheck warning SC2010 exists because
ls | grepcan fail with filenames containing special characters (spaces, newlines, etc.). While the current workflow files don't have such names, usingfindis the recommended best practice and makes the code more robust.Risk: Minimal - the output is identical for all current files, and the change only affects how files are discovered, not how they're processed.