Created
May 5, 2014 08:19
-
-
Save thvitt/11531321 to your computer and use it in GitHub Desktop.
A script that, for each argument, creates a shell script that calls `exec ‹argument› "$@"` in the current directory. Useful instead of symlinks for commands that refer to `$0` but that do not resolve symlinks.
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
#!/bin/sh | |
help() { | |
cat <<EOF | |
$0 /path/to/target/program ... | |
Creates a simple executable that forwards to the target program in the current | |
directory. | |
EOF | |
exit 255 | |
} | |
createSingleForward() { | |
target="$1" | |
forward=`basename "$1"` | |
cat > "$forward" <<EOF | |
#!/bin/sh | |
exec "$target" "\$@" | |
EOF | |
chmod 755 "$forward" | |
} | |
if [ "$#" -lt 1 -o "$1" = "--help" -o "$1" = "-h" ] | |
then | |
help | |
else | |
while [ $# -gt 0 ] | |
do | |
createSingleForward $1 | |
shift | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment