Skip to content

Instantly share code, notes, and snippets.

@dekokun
Created December 7, 2011 10:46
Show Gist options
  • Save dekokun/1442360 to your computer and use it in GitHub Desktop.
Save dekokun/1442360 to your computer and use it in GitHub Desktop.
直前のコマンドの成功失敗をみて色を変えながら成功失敗を出力するシェルスクリプトの関数
check()
{
local result=$?
local red=$'\e[0;31m'
local green=$'\e[0;32m'
local default=$'\e[m'
if [ $result -eq 0 ]
then
echo -n $green
echo $1 OK
echo -n $default
else
echo -n $red
echo $1 Fail
echo -n $default
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment