Skip to content

Commit

Permalink
Check if stdout is a terminal in lxc-checkconfig
Browse files Browse the repository at this point in the history
Let lxc-checkconfig write to non-tty stdout without color control
characters
Signed-off-by: walkerning <foxdoraame@gmail.com>
  • Loading branch information
walkerning committed May 1, 2016
1 parent 1970a77 commit 8513d8c
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 8513d8c

Please sign in to comment.