New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Looping over files with spaces. #609
Comments
Thanks for reporting this issue, don't forget to star this project to help us reach a wider audience. |
@preritdas Can you try using |
Didn't work, sadly. Same code but Output:
|
@preritdas Can you also put quotes around the output …
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v29.0.3
with:
files: "**/**.md"
separator: ","
- name: List all changed files
run: |
echo “${{ steps.changed-files.outputs.all_changed_files }}“
IFS=$','
for file in “${{ steps.changed-files.outputs.all_changed_files }}“
do echo “$file was changed”
done
unset IFS |
No cigar unfortunately. When wrapping the output in quotes, the entire output is treated as one file. Output below.
|
@preritdas Seems you'll need to tweak the code you have to resolve the issue. For example, you'll need to use ...
- name: List all modified files
run: |
IFS=$',' read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-files-comma.outputs.modified_files }}"
for file in "${MODIFIED_FILES_ARRAY[@]}"; do
echo $file
done
unset IFS
shell:
bash See this PR for more information. |
Yep, that does the trick. I appreciate the help. |
Hi, I've been looking through #216 and related information, including the use of
IFS
in BASH. Unfortunately, after countless attempts, I can't seem to get it to work with this action. I'm not sure if it's an issue with this action, a behavior of GitHub actions, or an error in my implementation.I'm opening this issue because I tried the same script on my Ubuntu server and it worked like a charm.
Attempt
Response
Expected
It seems the IFS is being changed because when I
echo ".$IFS."
after settingIFS=","
, the shell prints.,.
as expected. But when I loop, no change.As I mentioned earlier, I tried this on my own Ubuntu server and it worked
Which outputted...
Here is a shell recording of this working on WSL Ubuntu.
I apologize if I missed something basic and opened an issue when unnecessary. That said, I've tried countless variations of the script and looked through pretty much every mention of "space" and "IFS" in this repo and codebase, and haven't been able to resolve the issue. When the same script worked on my Ubuntu server, I decided it best to open this "issue." Thanks sincerely for any help.
The text was updated successfully, but these errors were encountered: