You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect way to handle directory read/write access checks in the test command #1116
Problem Description:
The current implementation of the TsWrite/TsRead case in the code does not correctly determine if a directory is writable/readable.
Specifically, the following snippet:
will fail when x refers to a directory because opening a directory with the os.O_WRONLY flag is not a valid operation. Consequently, the function will always return false for directories, even if they are writable.
changed the title [-]Incorrect way to handle directory Read/Write access check[/-][+]Incorrect way to handle directory Read/Write access check in `test` command[/+]on Dec 30, 2024
changed the title [-]Incorrect way to handle directory Read/Write access check in `test` command[/-][+]Incorrect way to handle directory read/write access checks in the test command[/+]on Dec 30, 2024
We already have some OS-dependent logic via os_unix.go and os_notunix.go. It would be perfectly fine to extend this to perform better on unix as you suggest; we would just need tests to cover the edge case above.
Activity
[-]Incorrect way to handle directory Read/Write access check[/-][+]Incorrect way to handle directory Read/Write access check in `test` command[/+][-]Incorrect way to handle directory Read/Write access check in `test` command[/-][+]Incorrect way to handle directory read/write access checks in the test command[/+]ic-it commentedon Jan 2, 2025
In this case, I suggest, use these solutions from here
Since there is no single and cross-platform solution, we can do it differently for different systems via
+buildThere is also an option to create a file to "check" if it can be written to the directory. But this approach is IMHO error-prone
mvdan commentedon Jan 2, 2025
We already have some OS-dependent logic via
os_unix.goandos_notunix.go. It would be perfectly fine to extend this to perform better on unix as you suggest; we would just need tests to cover the edge case above.interp: better support for directories in test -r, -w, -x checks
chore(deps): update module mvdan.cc/sh/v3/cmd/shfmt to v3.12.0 (hetzn…