Artix Linux Forum

Init systems => suite66-archived => Topic started by: kronikpillow on 20 September 2021, 16:06:28

Title: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 20 September 2021, 16:06:28
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?
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: ndowens on 20 September 2021, 16:36:20
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.
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: strajder on 20 September 2021, 16:47:11
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.
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 20 September 2021, 22:52:11
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?
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: ndowens on 20 September 2021, 22:53:36
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
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: strajder on 20 September 2021, 23:34:49
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.
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 20 September 2021, 23:35:11
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
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: Dudemanguy on 20 September 2021, 23:40:35
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.
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 20 September 2021, 23:51:44
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?
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: Dudemanguy on 21 September 2021, 00:00:33
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.
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 21 September 2021, 00:03:51
/usr/bin/reboot and /usr/bin/poweroff are execlineb ... what ever that is  :D   :o
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 21 September 2021, 00:40:07
if this is the correct link to upstream (https://framagit.org/Obarun) 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 :)
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: ndowens on 21 September 2021, 04:08:22
I added a patch locally to set it to bash, which will hit mirrors once they sync.
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: Dudemanguy on 21 September 2021, 05:36:48
if this is the correct link to upstream (https://framagit.org/Obarun) 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.
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: strajder on 21 September 2021, 12:24:07
[ ${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).
Title: [SOLVED] Re: when trying to run shutdown -p, i get a Bad substituion
Post by: capezotte on 21 September 2021, 14:23:02
A pure POSIX sh equivalent without pipes would be:

Code: [Select]
[ "${1%%"${1#?}"}" != '-' ] && die

OP should probably forward our code to Eric so he considers it for inclusion on 66.

edit: fix quotes
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: strajder on 21 September 2021, 18:29:12
I think you don't need those inner quotes though. Without them (test.sh),
Code: [Select]
#!/bin/sh
[ "${1%%${1#?}}" != '-' ] && echo not minus || echo minus
Code: [Select]
$ ./test.sh -abc def
minus
$ ./test.sh abc def
not minus
$ ./test.sh '-abc def'
minus
$ ./test.sh 'abc def'
not minus
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: capezotte on 21 September 2021, 19:47:51
Inner quotes are just to handle edge case of ./test.sh '-*abcdef' (and other globbing metacharacters).
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 23 September 2021, 10:32:32
I'v been waiting since day 1 of your first reply and idea to report to upstream, to get approved to that website, as they are supposedly being attacked by spam, and accounts take 1-5 days to get approved, what nonsense xD i can't even do a quick upstream bug report when I want to xD can anyone who already has a acc there, simply report the upstream bug report for me that the script makes a call to a POSIX compliant shell while uses bashisms?
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: ndowens on 23 September 2021, 10:39:47
https://framagit.org/Obarun/66 I would open an issue there
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 23 September 2021, 11:17:45
yeah except that they didn't approve my account, thats what im saying :D I can't open a issue without a account can i?
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: strajder on 23 September 2021, 11:22:59
You can maybe try here: Bug report / Obarun forum (https://forum.obarun.org/viewforum.php?id=2&i=1)
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 29 September 2021, 17:08:03
finally got approved and filed a bug report, I'v marked this topic can be closed i guess ... thanks for your help :) you guys are great :)
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: ndowens on 29 September 2021, 20:59:11
finally got approved and filed a bug report, I'v marked this topic can be closed i guess ... thanks for your help :) you guys are great :)
Locally I added a patch for the cmd, until atleast upstream decides to/not to do it.
Title: Re: when trying to run shutdown -p, i get a Bad substituion
Post by: kronikpillow on 06 October 2021, 13:17:29
seems that the issue is now solved on upstream issue: shutdown script (https://framagit.org/Obarun/66/-/issues/8)