winure/scripts/pwsh.sh

21 lines
478 B
Bash
Executable file

#!/usr/bin/bash
# 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
fi
# fall back to user installation
if [ -z ${PWSH+x} ]; then
PWSH="`userprofile`/AppData/Local/Microsoft/WindowsApps/pwsh.exe"
fi
# run target
"$PWSH" $@