]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
install-deps.sh: check if have access to stdout
authorKefu Chai <kchai@redhat.com>
Thu, 28 Dec 2017 02:18:11 +0000 (10:18 +0800)
committerNathan Cutler <ncutler@suse.com>
Fri, 4 Oct 2019 15:14:02 +0000 (17:14 +0200)
$- 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>
(cherry picked from commit 7bb8f66cf4e2519c33f1078c1be7485f9fe35a87)

install-deps.sh

index e2a5421c22e71df864d2261b56313218ad33f605..350c22567bc4991ae57aae5a54e0bb1edd0e70fa 100755 (executable)
@@ -71,10 +71,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
@@ -85,12 +84,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
 }