Skip to content

Instantly share code, notes, and snippets.

@syusui-s
Created May 10, 2017 11:20
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 syusui-s/314abc0496c0686f3d98b2968602cea6 to your computer and use it in GitHub Desktop.
Save syusui-s/314abc0496c0686f3d98b2968602cea6 to your computer and use it in GitHub Desktop.
ShellScript Utilities Libraries
#!/bin/sh
## @PosixCompatible
eecho() { echo "$*" > /dev/stderr; }
## @PosixCompatible
require_commands() {
(
missing=0
for cmd; do
if ! hash "$cmd" 1>/dev/null 2>&1; then
missing=1
eecho "command missing - '$cmd'"
fi
done
if [ "$missing" -gt 0 ]; then
eecho
eecho "To run this script, please install above commands."
return 1
fi
) || exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment