Patchwork [v2] initscripts: fix bashism in bootmisc.sh

login
register
mail settings
Submitter Ben Shelton
Date July 23, 2014, 4:22 p.m.
Message ID <1406132564-32476-1-git-send-email-ben.shelton@ni.com>
Download mbox | patch
Permalink /patch/76491/
State Accepted
Commit 7c11b327a1cf116ccfd3df05e84845dbcb3d3fd8
Headers show

Comments

Ben Shelton - July 23, 2014, 4:22 p.m.
In the commit 'initscripts: save /etc/timestamp with seconds accuracy',
a bashism was introduced in the bootmisc.sh script in the code to set
the current date from the stored value in /etc/timestamp.  This causes
that operation to fail with the following message when /bin/sh is not
bash:

/etc/init.d/rc: /etc/rcS.d/S55bootmisc.sh: line 73: syntax error: bad substitution

Fixed by using pattern matching removal rather than bash-specific
substring expansion.

[YOCTO #6566]

Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
 meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index ccc7f9f..df553bc 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -70,7 +70,11 @@  then
 	read TIMESTAMP < /etc/timestamp
 	if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
 		# format the timestamp as date expects it (2m2d2H2M4Y.2S)
-		date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
+		TS_YR=${TIMESTAMP%??????????}
+		TS_SEC=${TIMESTAMP#????????????}
+		TS_FIRST12=${TIMESTAMP%??}
+		TS_MIDDLE8=${TS_FIRST12#????}
+		date -u ${TS_MIDDLE8}${TS_YR}.${TS_SEC}
 		test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
 	fi
 fi