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