Created
May 10, 2017 11:20
-
-
Save syusui-s/314abc0496c0686f3d98b2968602cea6 to your computer and use it in GitHub Desktop.
ShellScript Utilities Libraries
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 | |
## @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