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 1809 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

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

Reply #15
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

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

Reply #16
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

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

Reply #17
Inner quotes are just to handle edge case of ./test.sh '-*abcdef' (and other globbing metacharacters).

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

Reply #18
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?


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

Reply #20
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?


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

Reply #22
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 :)

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

Reply #23
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.