]> code.ossystems Code Review - openembedded-core.git/commitdiff
initscripts: fix bashism in bootmisc.sh
authorBen Shelton <ben.shelton@ni.com>
Wed, 23 Jul 2014 16:22:44 +0000 (11:22 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Jul 2014 20:49:46 +0000 (21:49 +0100)
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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh

index ccc7f9f1f406569715c4e0101b032eb9465d2e99..df553bc079dba63a842d3b47433737066a6df001 100755 (executable)
@@ -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