Skip to content

Instantly share code, notes, and snippets.

@niedzielski
Last active February 10, 2018 22:41
Show Gist options
  • Save niedzielski/48be1d500079fd19afc643e9be2897c3 to your computer and use it in GitHub Desktop.
Save niedzielski/48be1d500079fd19afc643e9be2897c3 to your computer and use it in GitHub Desktop.
Shell wrapper for mapping an NPM-style command to a shell command.
#!/usr/bin/env sh
set -eu ${VERBOSE:+-x}
execute() {
local cmd="$1"
shift
case "$cmd" in
start) echo a b|exec xargs -P0 -n1 "$0";;
a) sleep 1; echo a; sleep 2; exec echo a;;
b) sleep 2; exec echo b "$@";;
c) execute b foo;;
*) ! :;;
esac
}
execute "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment