Skip to content

Instantly share code, notes, and snippets.

@rasjani
Created February 16, 2017 15:43
Show Gist options
  • Save rasjani/3719c75d3fefc5cff9c62039bf4c2297 to your computer and use it in GitHub Desktop.
Save rasjani/3719c75d3fefc5cff9c62039bf4c2297 to your computer and use it in GitHub Desktop.
use $PATHEXT variable in cygwin to find file extensions when executing commands ..
# 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
}
@rasjani
Copy link
Author

rasjani commented Feb 16, 2017

do know that this is a hack and possibly even a security issue ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment