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 env-share 2> /dev/null
# try to use system-wide version first. # try to use system-wide version first.
# this usually fails, but it's worth a shot. PWSH='/mnt/c/Program Files/PowerShell/7/pwsh.exe'
if [[ -r '/mnt/c/Program Files/WindowsApps/' ]]; then if [ -x "$PWSH" ]; then
cd '/mnt/c/Program Files/WindowsApps/' unset PWSH
PWSH="`pwd`/`find Microsoft.PowerShell_* -name 'pwsh.exe'`"
cd - > /dev/null
if ! [ -x "$PWSH" ]; then
unset PWSH
fi
fi fi
# fall back to user installation # fall back to System32
if [ -z ${PWSH+x} ]; then 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 fi
# run target # run target