Skip to contentSkip to conversation

base-files: profile: Whitespace clean up

PATCH Superseded Peter Kjellerstedt 2 participants 5 messages Apr 3, 2017 – Apr 4, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 base-files: profile: Whitespace clean up

---
 meta/recipes-core/base-files/base-files/profile | 29 +++++++++++++------------
 1 file changed, 15 insertions(+), 14 deletions(-)
meta/recipes-core/base-files/base-files/profile +15 -14
index c616616cee..22dfb4f219 100644
@@ -6,28 +6,29 @@ EDITOR="vi"			# needed for packages like cron, git-commit
 test -z "$TERM" && TERM="vt100"	# Basic terminal capab. For screen etc.
 
 if [ "$HOME" = "ROOTHOME" ]; then
-   PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
+	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\$ '
+	# works for bash and ash (no other shells known to be in use here)
+	PS1='\u@\h:\w\$ '
 fi
 
 if [ -d /etc/profile.d ]; then
-  for i in /etc/profile.d/*.sh ; do
-    if [ -f $i -a -r $i ]; then
-      . $i
-    fi
-  done
-  unset i
+	for i in /etc/profile.d/*.sh; do
+		if [ -f $i -a -r $i ]; then
+			. $i
+		fi
+	done
+	unset i
 fi
 
 if [ -x /usr/bin/resize ] && termpath="`tty`"; then
-  # Make sure we are on a serial console (i.e. the device used starts with /dev/tty),
-  # otherwise we confuse e.g. the eclipse launcher which tries do use ssh
-  case "$termpath" in
-  /dev/tty[A-z]*) resize >/dev/null
-  esac
+	# 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 "$termpath" in
+		/dev/tty[A-z]*) resize >/dev/null
+	esac
 fi
 
 export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
Signature · 1 line
2.12.0
#1 lore raw

PATCH 2/3 base-files: profile: Do not assume that the tty command exists

This avoids the following error when logging in to a host that does not have the tty command:

-sh: tty: not found

---
 meta/recipes-core/base-files/base-files/profile   | 6 +++---
 meta/recipes-core/base-files/base-files_3.0.14.bb | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)
meta/recipes-core/base-files/base-files/profile +3 -3
index 22dfb4f219..ceaf15f799 100644
@@ -22,12 +22,12 @@ if [ -d /etc/profile.d ]; then
 	unset i
 fi
 
-if [ -x /usr/bin/resize ] && termpath="`tty`"; then
+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 "$termpath" in
-		/dev/tty[A-z]*) resize >/dev/null
+	case $(tty) in
+		/dev/tty[A-z]*) resize >/dev/null;;
 	esac
 fi
 
meta/recipes-core/base-files/base-files_3.0.14.bb +0 -4
index f56969c52e..ca7bf06353 100644
@@ -128,10 +128,6 @@ do_install () {
 	install -m 0644 ${WORKDIR}/host.conf ${D}${sysconfdir}/host.conf
 	install -m 0644 ${WORKDIR}/motd ${D}${sysconfdir}/motd
 
-	if [ "/usr/bin" != "${bindir}" ]; then
-		sed -i "s,/usr/bin/resize,${bindir}/resize," ${D}${sysconfdir}/profile
-	fi
-
 	ln -sf /proc/mounts ${D}${sysconfdir}/mtab
 }
 
Signature · 1 line
2.12.0
#2 lore raw

PATCH 3/3 base-files: profile: Simplify setting variables conditionally

In reply to Peter Kjellerstedt

It is preferred to use [ "$FOO" ] || ... instead of [ -z "$FOO" ] && ... as the latter leaves $? set to 1.

---
 meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
meta/recipes-core/base-files/base-files/profile +6 -8
index ceaf15f799..a062028226 100644
@@ -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
Signature · 1 line
2.12.0
#3 lore raw

Re: [PATCH 3/3] base-files: profile: Simplify setting variables conditionally

Quoted 21 lines · Peter Kjellerstedt

It is preferred to use [ "$FOO" ] || ... instead of [ -z "$FOO" ] && ... as the latter leaves $? set to 1.

---
 meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
meta/recipes-core/base-files/base-files/profile +1 -3
index ceaf15f799..a062028226 100644
@@ -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

meta/recipes-core/base-files/base-files/profile line 12

Quoted 10 lines
meta/recipes-core/base-files/base-files/profile +5 -5
-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\$ '

Here you are using [ -z ] instead of [ ], is this intended? I do not think so based on your commit message.

Quoted 6 lines
meta/recipes-core/base-files/base-files/profile +0 -0
 if [ -d /etc/profile.d ]; then
 	for i in /etc/profile.d/*.sh; do
Signature · 1 line
2.12.0
#4 lore raw

Re: [PATCH 3/3] base-files: profile: Simplify setting variables conditionally

Quoted 29 lines

-----Original Message-----
From: Leonardo Sandoval [mailto:[email protected]]
Sent: den 3 april 2017 17:45
To: Peter Kjellerstedt <[email protected]>
Cc: [email protected]
Subject: Re: [OE-core] [PATCH 3/3] base-files: profile: Simplify setting variables conditionally

Quoted 19 lines · Peter Kjellerstedt

It is preferred to use [ "$FOO" ] || ... instead of [ -z "$FOO" ] && ... as the latter leaves $? set to 1.

---
 meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
meta/recipes-core/base-files/base-files/profile +1 -1
index ceaf15f799..a062028226 100644
@@ -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.
 
Quoted 15 lines

meta/recipes-core/base-files/base-files/profile line 12

Quoted 12 lines
meta/recipes-core/base-files/base-files/profile +5 -7
-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\$ '

Here you are using [ -z ] instead of [ ], is this intended? I do not think so based on your commit message.

Yes, it is intentional to maintain the original functionality. However, I may have to update the commit message a bit. It was written when I had only done the change for the $TERM variable.

Quoted 5 lines
Quoted 5 lines
meta/recipes-core/base-files/base-files/profile +0 -1
 if [ -d /etc/profile.d ]; then
 	for i in /etc/profile.d/*.sh; do
--

2.12.0

//Peter