trilom / file-changes-action

This action can be added, and you will get outputs of all of the files that have changed in your repository for you to use.
MIT License
167 stars 48 forks source link

Escaped file names #130

Open peterbe opened 2 years ago

peterbe commented 2 years ago

Is your feature request related to a problem? Please describe. Escaping names.

Imaging a PR that contains a change to a file that has brackets in it. E.g. foo-(bar).md And in my Actions workflow I do this:

  - run: ls ${{ steps.get_diff_files.outputs.files }}

what that translates to is:

  - run: ls foo-(bar).md

which will fail with:

no matches found: foo-(bar).md

But if it was escaped, it would work:

$ touch "foo-(bar).md"
$ ls -l "foo-(bar).md"
-rw-r--r--  1 peterbe  wheel  0 Jan 10 09:52 foo-(bar).md

You can't change the workflow Yaml to...

  - run: ls "${{ steps.get_diff_files.outputs.files }}"

because although bash would no longer crash, you'd end up with multiple files being treated as one long string with a space in it. E.g.

  - run: ls "foo-(bar).md other.file and/another/file.md"

Describe the solution you'd like That the string outputs.files escaped each and every file. Perhaps something like this:

      - name: Gather files changed
        uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
        id: get_diff_files
        with:
          escapeEachFile: true

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

peterbe commented 2 years ago

I use zsh but I think it's the same as bash. You can either escape each filename with quotation marks, but you can also just use \ on each control character that's problematic. E.g. ls foo-\(bar\).md will work the same as ls "foo-(bar).md". No idea which one is best.