]> code.ossystems Code Review - openembedded-core.git/commitdiff
base-files: profile: Avoid using "command" to determine if programs exist
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>
Thu, 19 Jul 2018 18:19:40 +0000 (20:19 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 26 Jul 2018 12:16:31 +0000 (13:16 +0100)
Since the existence of "command" in itself is not guaranteed, using it
to determine if other executables exist is moot. Instead just run the
executables and let the shell determine if they exist. By piping stderr
to /dev/null we avoid unnecessary warnings in case they do not exist.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/recipes-core/base-files/base-files/profile

index a06202822676bf8ca98e477e886b79f7d22a95b2..e14cb2d87881475b5f147cb1a6cddb85207088d0 100644 (file)
@@ -20,14 +20,16 @@ if [ -d /etc/profile.d ]; then
        unset i
 fi
 
-if command -v resize >/dev/null && command -v tty >/dev/null; then
-       # Make sure we are on a serial console (i.e. the device used starts with
-       # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
-       # tries do use ssh
-       case $(tty) in
-               /dev/tty[A-z]*) resize >/dev/null;;
-       esac
-fi
+# Make sure we are on a serial console (i.e. the device used starts with
+# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which tries do
+# use ssh
+case $(tty 2>/dev/null) in
+       # The first invocation of resize verifies that it exists, the second
+       # does the actual resizing. This is due to that resize uses stderr to
+       # determine the size of the tty, which does not work if it is redirected
+       # to /dev/null.
+       /dev/tty[A-z]*) resize >/dev/null 2>&1 && resize >/dev/null;;
+esac
 
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM