Skip to content
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

Bug: using absolute paths throws FileExistsError #12

Closed
lukaw3d opened this issue Aug 14, 2024 · 1 comment
Closed

Bug: using absolute paths throws FileExistsError #12

lukaw3d opened this issue Aug 14, 2024 · 1 comment

Comments

@lukaw3d
Copy link

lukaw3d commented Aug 14, 2024

$ docker run -v `pwd`:/app2 --rm quay.io/mschuette/yaml-shellcheck /app2/test-input/github-workflow.yml

2024-08-14 02:18:05,957 - root - INFO - read /app2/test-input/github-workflow.yml as GitHub Actions config...
Traceback (most recent call last):
  File "/app/yaml_shellcheck.py", line 459, in <module>
    main()
  File "/app/yaml_shellcheck.py", line 448, in main
    filenames.extend(write_tmp_files(args, result))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/yaml_shellcheck.py", line 402, in write_tmp_files
    subdir.mkdir(exist_ok=True, parents=True)
  File "/usr/local/lib/python3.12/pathlib.py", line 1311, in mkdir
    os.mkdir(self, mode)
FileExistsError: [Errno 17] File exists: '/app2/test-input/github-workflow.yml'

or

$ docker run -v `pwd`:`pwd` --rm quay.io/mschuette/yaml-shellcheck  `pwd`/**/*.y*ml
2024-08-14 02:32:29,902 - root - INFO - read /home/luka/Downloads/yaml-shellcheck/test-input/ansible-playbook.yml as Ansible file...
Traceback (most recent call last):
  File "/app/yaml_shellcheck.py", line 459, in <module>
    main()
  File "/app/yaml_shellcheck.py", line 448, in main
    filenames.extend(write_tmp_files(args, result))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/yaml_shellcheck.py", line 402, in write_tmp_files
    subdir.mkdir(exist_ok=True, parents=True)
  File "/usr/local/lib/python3.12/pathlib.py", line 1311, in mkdir
    os.mkdir(self, mode)
FileExistsError: [Errno 17] File exists: '/home/luka/Downloads/yaml-shellcheck/test-input/ansible-playbook.yml'

This happens because

subdir = outdir / filename

is just subdir = filename for absolute paths.

Naive fix

lukaw3d@8df5d64

$ docker run -v `pwd`:/app2 --rm ghcr.io/lukaw3d/yaml-shellcheck:main /app2/test-input/github-workflow.yml
2024-08-14 02:29:29,192 - root - INFO - read /app2/test-input/github-workflow.yml as GitHub Actions config...

In a/app2/test-input/github-workflow.yml/jobs/hello_world_job/steps/2/run line 2:
echo random-number $ACTION_EXPRESSION
                   ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
echo random-number "$ACTION_EXPRESSION"

For more information:
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
@mschuett
Copy link
Owner

mschuett commented Sep 9, 2024

fixed in the PR and released as part of v1.4.0

@mschuett mschuett closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants