Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: when trying to run shutdown -p, i get a Bad substituion (Read 1580 times) previous topic - next topic
0 Members and 4 Guests are viewing this topic.

when trying to run shutdown -p, i get a Bad substituion

when trying to run:
shutdown -p or any of the shutdown flags

I get a

/usr/bin/shutdown: 43: Bad substitution

anyone know how to solve this?

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #1
when trying to run:
shutdown -p or any of the shutdown flags

I get a

/usr/bin/shutdown: 43: Bad substitution

anyone know how to solve this?
I just tried : shutdown -p now and have no issue.

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #2
when trying to run:
shutdown -p or any of the shutdown flags

I get a

/usr/bin/shutdown: 43: Bad substitution

anyone know how to solve this?

What is the output of
Code: [Select]
$ ls -l /usr/bin/sh
on your system? If it's different than bash, symlink /usr/bin/bash to /usr/bin/sh and try again.

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #3
I use dash as it's faster then bash, but my login and interactive shell is ZSH, I would like to stay with dash as my /bin/sh ... is there a way i can work around this?

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #4
I use dash as it's faster then bash, but my login and interactive shell is ZSH, I would like to stay with dash as my /bin/sh ... is there a way i can work around this?
That is probably why you are having this issue. You'd possibly have to re-write the shutdown script to work with dash

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #5
In this case, it seems like it is breaking the system, which makes the other options better.

If you need a lightweight shell, I use mksh (MirBSD Korn Shell) for both /bin/sh and interactive use, and I don't have issues.

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #6
so the 66 utils were written in bash? :( what a headache, then possibly other 66 utils might have issues with dash as well? I am not well versed in scripting, I might as well just do a call to dash in my scripts that i want running trough dash to avoid the issue

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #7
I think it's just an error in 66. The scripts do have a #!/bin/sh shebang. Running checkbashisms on the shutdown script, it gives me this output.

Code: [Select]
possible bashism in shutdown_script line 43 (${foo:3[:1]}):
[ ${1:0:1} != '-' ] && die
The second one is definitely bash specific not sure about the first one. Probably worth an upstream bug report at any rate. Maybe there are others.

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #8
yeah i just changed the shebang on the shutdown script from /bin/sh to /bin/bash and solved the problem, I will file a upstream bug report ... but I am new to 66 utils, how do i easiest identify scripts that belong to Obarun?

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #9
Well all the init-specific stuff (shutdown, reboot, poweroff, etc.) are all Obarun. In s6-linux-init these are all written using execline not shell.

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #10
/usr/bin/reboot and /usr/bin/poweroff are execlineb ... what ever that is  :D   :o

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #11
if this is the correct link to upstream it seems to me that the only script in the 66 repo related to init that was written in shell is shutdown, so I'll file a bug report if that is the correct url, but a temp solution is to change the shebang from /bin/sh to /bin/bash to who ever encounters the same problem :)

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #12
I added a patch locally to set it to bash, which will hit mirrors once they sync.

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #13
if this is the correct link to upstream it seems to me that the only script in the 66 repo related to init that was written in shell is shutdown, so I'll file a bug report if that is the correct url, but a temp solution is to change the shebang from /bin/sh to /bin/bash to who ever encounters the same problem :)
Yup that's upstream.

Re: when trying to run shutdown -p, i get a Bad substituion

Reply #14
[ ${1:0:1} != '-' ] && die could be replaced by a call to sed:
Code: [Select]
[ "$(echo $1 | sed 's/^\(.\).*/\1/')" != '-' ] && die
The difference is that sed is (usually) an external program, which might not even be installed on the system, compared to Bash built-in substring expansion (man bash, then /Substring Expansion).