Skip to contentSkip to conversation

update-rc.d: Fix enable/disable command

PATCH In review Einar Gunnarsson 2 participants 2 messages Jul 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 update-rc.d: Fix enable/disable command

$[] is a bashism and does not work on POSIX shells.

enable/disable on links numbered 08 and 09 gave the error:
'bash: 100-08: value too great for base (error token is "08")' Links numbered 91-99 created a single digit link.

Links numbered 91 or higher now create a double digit link with a leading zero.

---
 update-rc.d | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
update-rc.d +1 -1
index c9355d7..95d1c22 100644
@@ -114,7 +114,7 @@ renamelink()
         # or stop link to start link with a sequence number equal to the difference of 100 minus the original sequence number.
 	if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then
 		oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3`
-		newnn=$[100-$oldnn]
+		newnn=$(printf "%02d" $((100-${oldnn#0})))
 		[ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}"
 		if [ $notreally -eq 0 ];then
 			mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn}
Signature · 1 line
2.17.1
#1 lore raw

Hello,

This was actually applied on saturday:
https://git.yoctoproject.org/cgit/cgit.cgi/update-rc.d/commit/?id=8636cf478d426b568c1be11dbd9346f67e03adac

Quoted 34 lines · Einar Gunnarsson

$[] is a bashism and does not work on POSIX shells.

enable/disable on links numbered 08 and 09 gave the error:
'bash: 100-08: value too great for base (error token is "08")' Links numbered 91-99 created a single digit link.

Links numbered 91 or higher now create a double digit link with a leading zero.

---
 update-rc.d | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
update-rc.d +1 -1
index c9355d7..95d1c22 100644
@@ -114,7 +114,7 @@ renamelink()
         # or stop link to start link with a sequence number equal to the difference of 100 minus the original sequence number.
 	if ls ${etcd}${lev}.d/${oldstartstop}*${bn} >/dev/null 2>&1; then
 		oldnn=`basename ${etcd}${lev}.d/${oldstartstop}*${bn}|cut -c2-3`
-		newnn=$[100-$oldnn]
+		newnn=$(printf "%02d" $((100-${oldnn#0})))
 		[ $verbose -eq 1 ] && echo "rename ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} -> ${etcd}${lev}.d/${newstartstop}${newnn}${bn}"
 		if [ $notreally -eq 0 ];then
 			mv ${etcd}${lev}.d/${oldstartstop}${oldnn}${bn} ${etcd}${lev}.d/${newstartstop}${newnn}${bn}
Signature · 1 line
2.17.1
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com