Created
November 26, 2014 17:39
-
-
Save farrrr/2afaf5bf95a6e90694b3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env bash | |
| ## setup parameters | |
| app_name='far-shell' | |
| debug_mode='0' | |
| ## basic setup tools | |
| msg() { | |
| printf '%b\n' "$1" >&2 | |
| } | |
| success() { | |
| if [ "$ret" -eq '0' ]; then | |
| msg "\e[32m[✔]\e[0m ${1}${2}" | |
| fi | |
| } | |
| error() { | |
| msg "\e[31m[✘]\e[0m ${1}${2}" | |
| exit 1 | |
| } | |
| debug() { | |
| if [ "$debug_mode" -eq '1' ] && [ "$ret" -gt '1' ]; then | |
| msg "An error occurred in function \"${FUNCNAME[$i+1]}\" on line ${BASH_LINENO[$i+1]}, we're sorry for that." | |
| fi | |
| } | |
| program_exists() { | |
| local ret='0' | |
| type $1 > /dev/null 2>&1 || { local ret='1'; } | |
| # throw error on non-zero return value | |
| if [ ! "$ret" -eq '0' ]; then | |
| error "$2" | |
| fi | |
| } | |
| # setup functions | |
| ## main | |
| msg "Welcome to $app_name!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment