On 11/03/2022 04:25, Christoph Anton Mitterer wrote:
Hey. I've noted that dash gives different behaviour when both -s and -c are used, depending on their order:
The order is irrelevant.
calestyo@heisenberg:~$ cat script date calestyo@heisenberg:~$ calestyo@heisenberg:~$ dash -s -c 'echo foo' script foo $ <--- this is dash's prompt, and it reads input from stdin
This has -s and -c options. Contrary to your analysis below, as has been answered on your Austin Group bug report, this has unspecified behaviour. dash can do whatever it wants here.
calestyo@heisenberg:~$ dash -c 'echo foo' -s script foo
This only has a -c option. -s appears after 'echo foo', which is a non-option, and is therefore also a non-option. This is required to set $0 to -s, $1 to script, and then try to print 'foo', which dash correctly implements.
The syntax to have both -s and -c options, but have -s appear after -c, is dash -c -s 'echo foo' script which behaves the same as the -s -c case. Cheers, Harald van Dijk