Skip to content

Commit

Permalink
install-deps.sh: check if have access to stdout
Browse files Browse the repository at this point in the history
$- is "hB" if launched via command line, and it is "himBH" only when
we are actually *in* an interactive shell. so checking "test -t 1" is
what we want.

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Dec 28, 2017
1 parent db04011 commit 4181351
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ function ensure_decent_gcc_on_rh {
local expected=5.1
local dts_ver=$1
if version_lt $old $expected; then
case $- in
*i*)
# interactive shell
cat <<EOF
if test -t 1; then
# interactive shell
cat <<EOF
Your GCC is too old. Please run following command to add DTS to your environment:
scl enable devtoolset-7 bash
Expand All @@ -94,12 +93,10 @@ source scl_source enable devtoolset-7
see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details.
EOF
;;
*)
# non-interactive shell
source /opt/rh/devtoolset-$dts_ver/enable
;;
esac
else
# non-interactive shell
source /opt/rh/devtoolset-$dts_ver/enable
fi
fi
}

Expand Down

0 comments on commit 4181351

Please sign in to comment.