Skip to main content

Timeline for Bash -c with positional parameters

Current License: CC BY-SA 4.0

15 events
when toggle format what by license comment
Aug 5, 2020 at 18:13 history edited Bruno Bronosky CC BY-SA 4.0
Make the code sample repeatably accurate.
May 22, 2020 at 12:41 comment added Stéphane Chazelas @poige, check in info bash 'expansion, parameter'. In the man page on Ubuntu, I find Omitting the colon results in a test only for a parameter that is unset
May 22, 2020 at 12:31 comment added poige @StéphaneChazelas I don't see the quoted text in any bash manual I have — neither in macOS, nor in Linux. man bash | grep -i existence finds no occurrences.
May 22, 2020 at 10:35 history edited Stéphane Chazelas CC BY-SA 4.0
newer versions of bash have now fixed that incorrect error message upon ${var?}
May 22, 2020 at 10:31 comment added Stéphane Chazelas @poige, bash has both ${var?error} and ${var:?error} like all Bourne-like shells. Note the if the colon is omitted, the operator tests only for existence in the bash manual.
May 22, 2020 at 9:38 comment added poige @StéphaneChazelas what is the purpose of adding ? directly after ${1? Bash has notation ${…:?…} which is documented and look similarly.
Aug 27, 2014 at 22:55 vote accept muru
Aug 27, 2014 at 15:57 comment added mikeserv Or you use a completely robust workaround (suggested by Stéphane Chazelas in comp.unix.shell) SHELL -c 'shift $1; command' 2 1 arg1 arg2 ... haha...
Aug 27, 2014 at 13:23 history edited Stéphane Chazelas CC BY-SA 3.0
added 216 characters in body
Aug 27, 2014 at 13:02 comment added iruvar sh -c 'shift "$2"; echo txt files are "$@"' tentative-arg0 3 2 *.txt is fantastically inventive!
Aug 27, 2014 at 11:45 history edited Stéphane Chazelas CC BY-SA 3.0
added 274 characters in body
Aug 27, 2014 at 11:19 comment added muru Ah, yes. That's an practically useful example.
Aug 27, 2014 at 10:59 comment added Stéphane Chazelas @muru, which is correct (and you probably don't have txt files in the current directory). See also bash -c 'echo "${1?}"' foo
Aug 27, 2014 at 10:51 comment added muru I just ran: bash -c 'echo txt files are "$@"' meaningful-arg0-for-error *.txt on Ubuntu 14.04, bash version 4.3.11(1)-release, and I got: txt files are *.txt. O.o
Aug 27, 2014 at 10:40 history answered Stéphane Chazelas CC BY-SA 3.0