Skip to content

Commit

Permalink
Merge pull request #993 from walkerning/check-tty
Browse files Browse the repository at this point in the history
Check if the stdout is a terminal in lxc-checkconfig
  • Loading branch information
stgraber committed May 1, 2016
2 parents 1970a77 + 8513d8c commit 0aeed83
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lxc/lxc-checkconfig.in
Expand Up @@ -6,10 +6,17 @@

CAT="cat"

SETCOLOR_SUCCESS="printf \\033[1;32m"
SETCOLOR_FAILURE="printf \\033[1;31m"
SETCOLOR_WARNING="printf \\033[1;33m"
SETCOLOR_NORMAL="printf \\033[0;39m"
if [ -t 1 ]; then
SETCOLOR_SUCCESS="printf \\033[1;32m"
SETCOLOR_FAILURE="printf \\033[1;31m"
SETCOLOR_WARNING="printf \\033[1;33m"
SETCOLOR_NORMAL="printf \\033[0;39m"
else
SETCOLOR_SUCCESS=":"
SETCOLOR_FAILURE=":"
SETCOLOR_WARNING=":"
SETCOLOR_NORMAL=":"
fi

is_set() {
$CAT $CONFIG | grep "$1=[y|m]" > /dev/null
Expand Down

0 comments on commit 0aeed83

Please sign in to comment.