Last active
May 27, 2016 12:24
-
-
Save cls/546f71fad99558af48ee to your computer and use it in GitHub Desktop.
Script to execute the next binary along in $PATH
This file contains hidden or 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
| #!/bin/sh | |
| dir=${1%/*} | |
| bin=${1##*/} | |
| shift | |
| unset flag | |
| set -f | |
| IFS=: | |
| for d in $PATH; do | |
| if [ "X$d" = "X$dir" ]; then | |
| flag=1 | |
| elif [ -n "$flag" ] && [ -x "$d/$bin" ]; then | |
| exec "$d/$bin" "$@" | |
| fi | |
| done | |
| printf "%s: no \`%s' found beyond \`%s' in \$PATH\n" "${0##*/}" "$bin" "$dir" >&2 | |
| exit 127 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage: