Created
February 16, 2017 15:43
-
-
Save rasjani/3719c75d3fefc5cff9c62039bf4c2297 to your computer and use it in GitHub Desktop.
use $PATHEXT variable in cygwin to find file extensions when executing commands ..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# place this into /etc/profile.d/pathext_handler.sh | |
command_not_found_handle() { | |
res=127 | |
cmd=$1 | |
if [ ! -z "${PATHEXT-x}" ]; then | |
cmd=$1 | |
shift | |
OIFS=$IFS | |
IFS=';' | |
for ext in ${PATHEXT}; do | |
fullcmd=${cmd}${ext} | |
which ${fullcmd} > /dev/null 2>&1 | |
if [ $? == 0 ]; then | |
$fullcmd $* | |
res=$? | |
IFS=$OIFS | |
return $res | |
fi | |
done | |
IFS=$OIFS | |
fi | |
echo -`basename $SHELL`: $cmd: command not found | |
return $res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
do know that this is a hack and possibly even a security issue ..