Issue: `gsudo` script fails missing `gsudo.exe` in MSYS env
KSR-Yasuda opened this issue · 2 comments
KSR-Yasuda commented
Issue Description
In MSYS env, running gsudo
command, that refers to the shell script, comes to fail due to gsudo.exe
missing.
% gsudo --version
/c/Program Files/gsudo/Current/gsudo: 行 12: ./gsudo.exe: No such file or directory
# `gsudo` command (the shell script one) fails.
# It searches for the binary `gsudo.exe` in the current dir.
% type -a gsudo
gsudo is /c/Program Files/gsudo/Current/gsudo
% sudo --version
gsudo v2.4.3 (Branch.tags-v2.4.3.Sha.7da1395544bc53ecba069ff21c490f4922ce055c)
Copyright(c) 2019-2022 Gerardo Grignoli and GitHub contributors
# `sudo` command (`sudo.exe`) does work expectedly.
% type -a sudo
sudo is /c/Program Files/gsudo/Current/sudo
It looks readlink
command is returning nothing for gsudo
script path, that is not a symbolic link.
Then, it searches in dirname ""
or .
directory to find nothing.
With -f
option to readlink
, it works.
--- "a/c/Program Files/gsudo/Current/gsudo"
+++ "b/c/Program Files/gsudo/Current/gsudo"
@@ -8,5 +8,5 @@
# For better experience (fix credentials cache) in git-bash/MinGw create this wrapper can be added as function in .bashrc:
# gsudo() { WSLENV=WSL_DISTRO_NAME:USER:$WSLENV MSYS_NO_PATHCONV=1 gsudo.exe "$@"; }
-thisdir="$(dirname "$(readlink "$0")")"
+thisdir="$(dirname "$(readlink -f "$0")")"
WSLENV=WSL_DISTRO_NAME:USER:$WSLENV MSYS_NO_PATHCONV=1 "${thisdir}/gsudo.exe" "$@"
% gsudo --version
gsudo v2.4.3 (Branch.tags-v2.4.3.Sha.7da1395544bc53ecba069ff21c490f4922ce055c)
Copyright(c) 2019-2022 Gerardo Grignoli and GitHub contributors
Steps to Reproduce
As above.
Screenshots
Context:
- Windows version: Windows 11 Pro 23H2 (
[Version 10.0.22631.3155]
)
- gsudo version: v2.4.3
% pacman -Q msys2-runtime
msys2-runtime 3.4.10-5
% cmd version
Microsoft Windows [Version 10.0.22631.3155]
(c) Microsoft Corporation. All rights reserved.
# Windows 11 Pro 23H2
% readlink --version
readlink (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Dmitry V. Levin.
KSR-Yasuda commented
Thank you!