Skip to content

Commit 94e73e5

Browse files
authored
Update batch spec search result looping example (#870)
The original snippet has some issues: The loop will not handle spaces correctly and may misinterpret the path. The entire string is treated as one entity due to the quotes, leading to incorrect processing. Updated the loop handling in the script to correctly process file paths by switching from space-delimited to newline-delimited entries. This ensures the handling of paths with spaces or special characters. Added IFS=$'\n' for proper splitting and quoting of paths in the loop for safety. ![Screenshot 2024-12-19 at 3 10 35 PM](https://github.com/user-attachments/assets/4f10c4bb-cba2-4659-862f-4980c2c0b7c1) Spaces in file names ![Screenshot 2024-12-19 at 3 09 23 PM](https://github.com/user-attachments/assets/771935b7-6d84-4bf7-bc0e-f7fe1b01959c) ## 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.
1 parent f5cf41b commit 94e73e5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/batch-changes/batch-spec-cheat-sheet.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ on:
1414

1515
steps:
1616
- run: |
17-
for file in "${{ join repository.search_result_paths " " }}";
17+
IFS=$'\n'
18+
files="${{ join repository.search_result_paths "\n" }}"
19+
for file in $files;
1820
do
19-
sed -i 's/OLD-VALUE/NEW-VALUE/g;' ${file}
21+
sed -i 's/OLD-VALUE/NEW-VALUE/g;' "${file}"
2022
done
2123
container: alpine:3
2224
```

0 commit comments

Comments
 (0)