Skip to content

Instantly share code, notes, and snippets.

@fcurella
Created January 8, 2013 15:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcurella/4484708 to your computer and use it in GitHub Desktop.
Save fcurella/4484708 to your computer and use it in GitHub Desktop.
subcommand wrapper
#!/bin/sh
SUBCOMMAND=$0-$1;
ORIGINAL_COMMAND=/bin/echo
command -v $SUBCOMMAND >/dev/null 2>&1 || {
exec $ORIGINAL_COMMAND $*;
exit 1;
}
exec $0-$*;
exit 1;
#!/bin/sh
echo "hello, world" $*
$ ./echo test
test
$ ./echo hello
hello, world
$ ./echo hello test
hello, world test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment