Skip to content

Instantly share code, notes, and snippets.

@darkliquid
Created March 25, 2019 09:20
Show Gist options
  • Save darkliquid/9f09e49423d5ead2ab44267da5d2dfc8 to your computer and use it in GitHub Desktop.
Save darkliquid/9f09e49423d5ead2ab44267da5d2dfc8 to your computer and use it in GitHub Desktop.
WSL: Try to run .exe versions if they exist and the non .exe version doesn't
# WSL: Try to run .exe versions if they exist and the non .exe version doesn't
command_not_found_handle() {
if cmd.exe /c "(where $1 || (help $1 |findstr /V Try)) >nul 2>nul && ($* || exit 0)"; then
return $?
else
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment