]> code.ossystems Code Review - openembedded-core.git/commitdiff
base-files: profile: Simplify setting variables conditionally
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>
Mon, 3 Apr 2017 12:48:27 +0000 (14:48 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 16 May 2017 13:08:15 +0000 (14:08 +0100)
It is preferred to use `[ "$FOO" ] || ...` instead of
`[ -z "$FOO" ] && ...` as the latter leaves $? set to 1.

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 ceaf15f799b7771b66865ffe101b61e71fddece4..a06202822676bf8ca98e477e886b79f7d22a95b2 100644 (file)
@@ -3,15 +3,13 @@
 
 PATH="/usr/local/bin:/usr/bin:/bin"
 EDITOR="vi"                    # needed for packages like cron, git-commit
-test -z "$TERM" && TERM="vt100"        # Basic terminal capab. For screen etc.
+[ "$TERM" ] || TERM="vt100"    # Basic terminal capab. For screen etc.
 
-if [ "$HOME" = "ROOTHOME" ]; then
-       PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
-fi
-if [ "$PS1" ]; then
-       # works for bash and ash (no other shells known to be in use here)
-       PS1='\u@\h:\w\$ '
-fi
+# Add /sbin & co to $PATH for the root user
+[ "$HOME" != "ROOTHOME" ] || PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
+
+# Set the prompt for bash and ash (no other shells known to be in use here)
+[ -z "$PS1" ] || PS1='\u@\h:\w\$ '
 
 if [ -d /etc/profile.d ]; then
        for i in /etc/profile.d/*.sh; do