[oe-commits] [openembedded-core] 18/58: base-files: profile: Avoid using "command" to determine if programs exist

git at git.openembedded.org git at git.openembedded.org
Wed Jul 25 21:45:48 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit b1706ee3488cd04b1789a1205a6938ff915255f3
Author: Peter Kjellerstedt <peter.kjellerstedt at axis.com>
AuthorDate: Thu Jul 19 20:19:40 2018 +0200

    base-files: profile: Avoid using "command" to determine if programs exist
    
    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 at axis.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/recipes-core/base-files/base-files/profile | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/meta/recipes-core/base-files/base-files/profile b/meta/recipes-core/base-files/base-files/profile
index a062028..e14cb2d 100644
--- a/meta/recipes-core/base-files/base-files/profile
+++ b/meta/recipes-core/base-files/base-files/profile
@@ -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
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list