scripts: 'pwsh' now uses a more reliable path and fallback

This commit is contained in:
Valerie Wolfe 2024-07-15 10:26:31 -04:00
parent c96fc7bbcb
commit bf3e86a5df

View file

@ -3,19 +3,14 @@
env-share 2> /dev/null
# try to use system-wide version first.
# this usually fails, but it's worth a shot.
if [[ -r '/mnt/c/Program Files/WindowsApps/' ]]; then
cd '/mnt/c/Program Files/WindowsApps/'
PWSH="`pwd`/`find Microsoft.PowerShell_* -name 'pwsh.exe'`"
cd - > /dev/null
if ! [ -x "$PWSH" ]; then
unset PWSH
fi
PWSH='/mnt/c/Program Files/PowerShell/7/pwsh.exe'
if [ -x "$PWSH" ]; then
unset PWSH
fi
# fall back to user installation
# fall back to System32
if [ -z ${PWSH+x} ]; then
PWSH="`dos-var -p USERPROFILE`/AppData/Local/Microsoft/WindowsApps/pwsh.exe"
PWSH='/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe'
fi
# run target