Skip to content

Commit

Permalink
Update 'loop over paths in file' example (#872)
Browse files Browse the repository at this point in the history
Replaced the cat-based approach with a direct input redirection method
using `while IFS= read -r`. This change ensures proper handling of the
last line which doesn't have a trailing new line.

## Pull Request approval

You will need to get your PR approved by at least one member of the
Sourcegraph team. For reviews of docs formatting, styles, and component
usage, please tag the docs team via the #docs Slack channel.
  • Loading branch information
gabtorre authored Dec 20, 2024
1 parent 94e73e5 commit aaa1d78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/batch-changes/batch-spec-cheat-sheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ on:

steps:
- run: |
cat /tmp/search-results | while read file;
while IFS= read -r file || [ -n "$file" ]
do
sed -i 's/OLD-VALUE/NEW-VALUE/g;' "${file}"
done
done < /tmp/search-results
container: alpine:3
files:
/tmp/search-results: ${{ join repository.search_result_paths "\n" }}
Expand Down

0 comments on commit aaa1d78

Please sign in to comment.