Re: [PATCH 4/4] script(1): explicitly specify sh -c
On Mon, Jan 03, 2022 at 09:33:19PM +0100, ?? wrote: > On Sun, Jan 02, 2022 at 11:52:49PM +, Jason McIntyre wrote: > > On Sun, Jan 02, 2022 at 11:47:04PM +0100, ?? wrote: > > > On Sun, Jan 02, 2022 at 06:56:37PM +, Jason McIntyre wrote: > > > > On Sat, Jan 01, 2022 at 11:07:49PM +0100, ?? wrote: > > > > > @@ -69,8 +69,8 @@ retaining the prior contents. > > > > > .It Fl c Ar command > > > > > Run > > > > > .Ar command > > > > > +.Pq via Nm sh Fl c Ar command > > > > > instead of an interactive shell. > > > > > > > > or i suppose we could say > > > > > > > > Run > > > > .Nm sh Fl c Ar command , > > > > instead of an interactive shell. > > > Agree, this is much better phrasing, cheers. > > > > > > > > -To run a command with arguments, enclose both in quotes. > > > > why do you want to remove this line? the page is short, and it might > > > > help someone. > > > Because the value for -c is a *shell script*, not a command ??? > > > > i don;t follow. you can run: > > > > $ script -c ls > > > > i.e. a command, not a shell script/ > No, "ls" is definitely a shell script. It forks, execps ["ls"], waits, > then exits with WEXITSTATUS() or 128+WTERMSIG(). > In many ways this is not that different than if you'd ran > `script -c exec\ ls`, in which case the shell would just execp ["ls"]. > > > > I didn't think to change it out ??? it's much more confusing to have this > > > include mention of arguments when, well, they aren't: this reads as-if > > > script -c 'echo a || b' > > > ran ["echo", "a", "||", "b"] ??? you can see issue here. > > why would you think this? the text just explains that if you have > > command+args you should quote it. > Which means absolutely nothing, because script -c doesn't take a command > or arguments ??? it takes a shell program as the argument, which either > starts at the next byte, if non-NUL, or is the entire next argument > (XBD 12.1.2.a). > > Maybe I'm too hopeful in assuming the baseline of understanding how > shell tokenisation works in the user? > > > > -To run a command with arguments, enclose both in quotes. > > > +Scripts longer than just the name of a command need to be quoted, > > > +and are subject to re-expansion. > > that's a horrible sentence. i don;t see any improvement. > Sure. Given this and Matthew's post, I've opted to leave both the Ar > name and sentence as-is. > > Scissor-patch below. > committed, thanks. > Also, unrelatedly, does your MUA just completely give up when decoding > UTF-8 and convert each byte to a "?", or? > yes. i do not have any locale stuff set. jmc > -- >8 -- > Subject: [PATCH v3 4/4] script(1): explicitly specify sh -c > > The original wording is weird and doesn't explicitly say that it does > sh -c, which is the fundamental point ??? spell it out directly > --- > usr.bin/script/script.1 | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1 > index 28783961a..857b387b6 100644 > --- a/usr.bin/script/script.1 > +++ b/usr.bin/script/script.1 > @@ -68,7 +68,7 @@ or > retaining the prior contents. > .It Fl c Ar command > Run > -.Ar command > +.Nm sh Fl c Ar command > instead of an interactive shell. > To run a command with arguments, enclose both in quotes. > .El > -- > 2.30.2 >
Re: [PATCH 4/4] script(1): explicitly specify sh -c
On Sun, Jan 02, 2022 at 11:52:49PM +, Jason McIntyre wrote: > On Sun, Jan 02, 2022 at 11:47:04PM +0100, ?? wrote: > > On Sun, Jan 02, 2022 at 06:56:37PM +, Jason McIntyre wrote: > > > On Sat, Jan 01, 2022 at 11:07:49PM +0100, ?? wrote: > > > > @@ -69,8 +69,8 @@ retaining the prior contents. > > > > .It Fl c Ar command > > > > Run > > > > .Ar command > > > > +.Pq via Nm sh Fl c Ar command > > > > instead of an interactive shell. > > > > > > or i suppose we could say > > > > > > Run > > > .Nm sh Fl c Ar command , > > > instead of an interactive shell. > > Agree, this is much better phrasing, cheers. > > > > > > -To run a command with arguments, enclose both in quotes. > > > why do you want to remove this line? the page is short, and it might > > > help someone. > > Because the value for -c is a *shell script*, not a command ??? > > i don;t follow. you can run: > > $ script -c ls > > i.e. a command, not a shell script/ No, "ls" is definitely a shell script. It forks, execps ["ls"], waits, then exits with WEXITSTATUS() or 128+WTERMSIG(). In many ways this is not that different than if you'd ran `script -c exec\ ls`, in which case the shell would just execp ["ls"]. > > I didn't think to change it out ??? it's much more confusing to have this > > include mention of arguments when, well, they aren't: this reads as-if > > script -c 'echo a || b' > > ran ["echo", "a", "||", "b"] ??? you can see issue here. > why would you think this? the text just explains that if you have > command+args you should quote it. Which means absolutely nothing, because script -c doesn't take a command or arguments ‒ it takes a shell program as the argument, which either starts at the next byte, if non-NUL, or is the entire next argument (XBD 12.1.2.a). Maybe I'm too hopeful in assuming the baseline of understanding how shell tokenisation works in the user? > > -To run a command with arguments, enclose both in quotes. > > +Scripts longer than just the name of a command need to be quoted, > > +and are subject to re-expansion. > that's a horrible sentence. i don;t see any improvement. Sure. Given this and Matthew's post, I've opted to leave both the Ar name and sentence as-is. Scissor-patch below. Also, unrelatedly, does your MUA just completely give up when decoding UTF-8 and convert each byte to a "?", or? -- >8 -- Subject: [PATCH v3 4/4] script(1): explicitly specify sh -c The original wording is weird and doesn't explicitly say that it does sh -c, which is the fundamental point ‒ spell it out directly --- usr.bin/script/script.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1 index 28783961a..857b387b6 100644 --- a/usr.bin/script/script.1 +++ b/usr.bin/script/script.1 @@ -68,7 +68,7 @@ or retaining the prior contents. .It Fl c Ar command Run -.Ar command +.Nm sh Fl c Ar command instead of an interactive shell. To run a command with arguments, enclose both in quotes. .El -- 2.30.2 signature.asc Description: PGP signature
Re: [PATCH 4/4] script(1): explicitly specify sh -c
On Sun, Jan 02, 2022 at 11:47:04PM +0100, ?? wrote: > On Sun, Jan 02, 2022 at 06:56:37PM +, Jason McIntyre wrote: > > On Sat, Jan 01, 2022 at 11:07:49PM +0100, ?? wrote: > > > @@ -69,8 +69,8 @@ retaining the prior contents. > > > .It Fl c Ar command > > > Run > > > .Ar command > > > +.Pq via Nm sh Fl c Ar command > > > instead of an interactive shell. > > > > or i suppose we could say > > > > Run > > .Nm sh Fl c Ar command , > > instead of an interactive shell. > Agree, this is much better phrasing, cheers. > > > > -To run a command with arguments, enclose both in quotes. > > why do you want to remove this line? the page is short, and it might > > help someone. > Because the value for -c is a *shell script*, not a command ??? i don;t follow. you can run: $ script -c ls i.e. a command, not a shell script/ > I didn't think to change it out ??? it's much more confusing to have this > include mention of arguments when, well, they aren't: this reads as-if > script -c 'echo a || b' > ran ["echo", "a", "||", "b"] ??? you can see issue here. > why would you think this? the text just explains that if you have command+args you should quote it. > This is in contrast to, e.g., FreeBSD script(1), which has a > script outfile argv0 argv1 argvn... > usage. > ugh > -To run a command with arguments, enclose both in quotes. > +Scripts longer than just the name of a command need to be quoted, > +and are subject to re-expansion. that's a horrible sentence. i don;t see any improvement. jmc > I've applied your phrasing to the first hunk, re-phrased the quoting > requirement, and re-named the Ar name from "command" to "script". > This does introduce a minor ambiguity in that script is heavily loaded > here, but "shell program", while more correct, is not the usual > parlance; dunno ??? please see scissor-patch below. > > P.S.: I forgot to note this in the original patchset, > but please keep me in CC, as I'm not subscribed. > > -- >8 -- > Subject: [PATCH v2 4/4] script(1): explicitly specify sh -c, > rename argument name > > The original wording is weird and doesn't explicitly say that it does > sh -c, which is the fundamental point ??? spell it out directly, > and clear up the quoting requirement: -c takes a shell program, > not a command > --- > usr.bin/script/script.1 | 9 + > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1 > index 28783961a..18802504c 100644 > --- a/usr.bin/script/script.1 > +++ b/usr.bin/script/script.1 > @@ -39,7 +39,7 @@ > .Sh SYNOPSIS > .Nm script > .Op Fl a > -.Op Fl c Ar command > +.Op Fl c Ar script > .Op Ar file > .Sh DESCRIPTION > .Nm > @@ -66,11 +66,12 @@ Append the output to > or > .Pa typescript , > retaining the prior contents. > -.It Fl c Ar command > +.It Fl c Ar script > Run > -.Ar command > +.Nm sh Fl c Ar script > instead of an interactive shell. > -To run a command with arguments, enclose both in quotes. > +Scripts longer than just the name of a command need to be quoted, > +and are subject to re-expansion. > .El > .Pp > The script ends when the forked program exits (an > -- > 2.30.2
Re: [PATCH 4/4] script(1): explicitly specify sh -c
On Sun, Jan 02, 2022 at 06:56:37PM +, Jason McIntyre wrote: > On Sat, Jan 01, 2022 at 11:07:49PM +0100, ?? wrote: > > @@ -69,8 +69,8 @@ retaining the prior contents. > > .It Fl c Ar command > > Run > > .Ar command > > +.Pq via Nm sh Fl c Ar command > > instead of an interactive shell. > > or i suppose we could say > > Run > .Nm sh Fl c Ar command , > instead of an interactive shell. Agree, this is much better phrasing, cheers. > > -To run a command with arguments, enclose both in quotes. > why do you want to remove this line? the page is short, and it might > help someone. Because the value for -c is a *shell script*, not a command ‒ I didn't think to change it out ‒ it's much more confusing to have this include mention of arguments when, well, they aren't: this reads as-if script -c 'echo a || b' ran ["echo", "a", "||", "b"] ‒ you can see issue here. This is in contrast to, e.g., FreeBSD script(1), which has a script outfile argv0 argv1 argvn... usage. I've applied your phrasing to the first hunk, re-phrased the quoting requirement, and re-named the Ar name from "command" to "script". This does introduce a minor ambiguity in that script is heavily loaded here, but "shell program", while more correct, is not the usual parlance; dunno ‒ please see scissor-patch below. P.S.: I forgot to note this in the original patchset, but please keep me in CC, as I'm not subscribed. -- >8 -- Subject: [PATCH v2 4/4] script(1): explicitly specify sh -c, rename argument name The original wording is weird and doesn't explicitly say that it does sh -c, which is the fundamental point ‒ spell it out directly, and clear up the quoting requirement: -c takes a shell program, not a command --- usr.bin/script/script.1 | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1 index 28783961a..18802504c 100644 --- a/usr.bin/script/script.1 +++ b/usr.bin/script/script.1 @@ -39,7 +39,7 @@ .Sh SYNOPSIS .Nm script .Op Fl a -.Op Fl c Ar command +.Op Fl c Ar script .Op Ar file .Sh DESCRIPTION .Nm @@ -66,11 +66,12 @@ Append the output to or .Pa typescript , retaining the prior contents. -.It Fl c Ar command +.It Fl c Ar script Run -.Ar command +.Nm sh Fl c Ar script instead of an interactive shell. -To run a command with arguments, enclose both in quotes. +Scripts longer than just the name of a command need to be quoted, +and are subject to re-expansion. .El .Pp The script ends when the forked program exits (an -- 2.30.2 signature.asc Description: PGP signature
Re: [PATCH 4/4] script(1): explicitly specify sh -c
On Sat, Jan 01, 2022 at 11:07:49PM +0100, ?? wrote: > The original wording is weird and doesn't explicitly say that it does > sh -c, which is the fundamental point ??? spell it out directly > --- > usr.bin/script/script.1 | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1 > index 28783961a..b9a0f0411 100644 > --- a/usr.bin/script/script.1 > +++ b/usr.bin/script/script.1 > @@ -69,8 +69,8 @@ retaining the prior contents. > .It Fl c Ar command > Run > .Ar command > +.Pq via Nm sh Fl c Ar command > instead of an interactive shell. or i suppose we could say Run .Nm sh Fl c Ar command , instead of an interactive shell. > -To run a command with arguments, enclose both in quotes. why do you want to remove this line? the page is short, and it might help someone. jmc > .El > .Pp > The script ends when the forked program exits (an > -- > 2.30.2