Open dgleba opened 3 years ago
chmod
is not supposed to work in msys2. To change file permission, use icacls
or takeown
like commands which are specific to Microsoft Windows OS.
Hum.... Then perhaps chmod shouldn't exists within MSYS2 space? I came here just as I discovered I couldn't apply executable to a shell script.
touch blah.sh
chmod 744 blah.sh
ls -rtl blah.sh
-rw-r--r-- 1 et5341 Corp+Group(2371) 87 Aug 3 11:49 blah.sh
Actually, something is weird with MSYS2 displaying the permission...
$ ls -rtl
total 6
-rwxr-xr-x 1 et5341 Corp+Group(2371) 1002 Jul 7 09:56 mock-installed.sh
-rw-r--r-- 1 et5341 Corp+Group(2371) 87 Aug 3 11:49 blah-from-msys2.sh
-rw-r--r-- 1 et5341 Corp+Group(2371) 87 Aug 3 11:58 blah-created-from-ubuntu22.sh
So the mock-installed.sh
was a script that was created a while back, checked out from git, and some how it has the proper executable bit set correctly... however, the other 2 new files I tried to create, they don't. The one created from the Ubuntu 22.04 WSL2, it was chmod 755
and it still wouldn't show the executable bit under MSYS2... however if I ls
the files in Ubuntu, everything shows up correctly with the executable bit set..?
Add a shebang line in the shell script. It would automatically become executable.
Ok, shebang'ed worked. Thanks. 😄
@totszwai, not to interfere with your original issue, but that works on both Cygwin:
... and on Midipix:
icacls
doesn't seem to work either despite it saying it did. Here is an example in trying to make a file be readable only by the current user:
runneradmin@fv-az1434-66 MINGW64 ~
# icacls "$temp_key_file" /inheritance:r /remove:g "*S-1-1-0" /remove:g "*S-1-5-32-545"
processed file: C:/msys64/home/runneradmin/tmp.DYnm99oPwk
Successfully processed 1 files; Failed processing 0 files
runneradmin@fv-az1434-66 MINGW64 ~
# stat -c "%a %n" "$temp_key_file"
644 /home/runneradmin/tmp.DYnm99oPwk
runneradmin@fv-az1434-66 MINGW64 ~
# icacls "$temp_key_file" /grant:r "$USERNAME:(R)"
processed file: C:/msys64/home/runneradmin/tmp.DYnm99oPwk
Successfully processed 1 files; Failed processing 0 files
runneradmin@fv-az1434-66 MINGW64 ~
# stat -c "%a %n" "$temp_key_file"
644 /home/runneradmin/tmp.DYnm99oPwk
Running icacls within powershell.exe in a bash shell did the job.
Describe the issue
chmod is ignored by msys2 proper.
chmod og-r file.txt
has no effect.After reading several posts on the web and looking for a document to describe the way it should work, I am left with no clear answer.
This issue has little useful info. https://github.com/msys2/MSYS2-packages/issues/2016
How should it work? Did I miss the document that describes how it should work?
Steps to Reproduce the Problem