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.
What is the output of
$ 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.
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
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.
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
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.
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.
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?
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.
/usr/bin/reboot and /usr/bin/poweroff are execlineb ... what ever that is :D :o
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 :)
I added a patch locally to set it to bash, which will hit mirrors once they sync.
[ ${1:0:1} != '-' ] && die could be replaced by a call to sed:
[ "$(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).
A pure POSIX sh equivalent without pipes would be:
[ "${1%%"${1#?}"}" != '-' ] && die
OP should probably forward our code to Eric so he considers it for inclusion on 66.
edit: fix quotes
I think you don't need those inner quotes though. Without them (test.sh),
#!/bin/sh
[ "${1%%${1#?}}" != '-' ] && echo not minus || echo minus
$ ./test.sh -abc def
minus
$ ./test.sh abc def
not minus
$ ./test.sh '-abc def'
minus
$ ./test.sh 'abc def'
not minus
Inner quotes are just to handle edge case of ./test.sh '-*abcdef' (and other globbing metacharacters).
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?
https://framagit.org/Obarun/66 I would open an issue there
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?
You can maybe try here: Bug report / Obarun forum (https://forum.obarun.org/viewforum.php?id=2&i=1)
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.
seems that the issue is now solved on upstream issue: shutdown script (https://framagit.org/Obarun/66/-/issues/8)