9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] awk(1): quote argument for -v option
@ 2022-11-29 12:10 Anders Damsgaard
  2022-11-29 13:47 ` qwx
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Anders Damsgaard @ 2022-11-29 12:10 UTC (permalink / raw)
  To: 9front

Dear all,

Running awk from rc, I found that I need to quote the arguments to awk's
-v option, as in:

	awk -v 'myvar=asdf' 'BEGIN{print myvar}'

However, the awk man page specifies this without quotes as "awk -v
myvar=asdf".  I now realize that it will not work without quotes because
rc tries to interpret the assignment operator.

Is this just a beginner mistake, being used to unix behavior, or worth
documenting as in the patch below?

Thanks, Anders


diff ff2ebe6cfdacd890a74a6d2f9b0acd062d2633b7 uncommitted
--- a/sys/man/1/awk
+++ b/sys/man/1/awk
@@ -23,7 +23,7 @@
  ]
  [
  .B -v
-.I var=value
+.I 'var=value'
  ]
  [
  .B -f
@@ -58,13 +58,13 @@
  Any
  .IR file
  of the form
-.I var=value
+.I 'var=value'
  is treated as an assignment, not a file name,
  and is executed at the time it would have been opened if it were a file name.
  The option
  .B -v
  followed by
-.I var=value
+.I 'var=value'
  is an assignment to be done before the program
  is executed;
  any number of

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 12:10 [9front] [PATCH] awk(1): quote argument for -v option Anders Damsgaard
@ 2022-11-29 13:47 ` qwx
  2022-11-29 14:52 ` Stanley Lieber
  2022-11-29 15:14 ` Kurt H Maier
  2 siblings, 0 replies; 10+ messages in thread
From: qwx @ 2022-11-29 13:47 UTC (permalink / raw)
  To: 9front

On Tue Nov 29 13:11:23 +0100 2022, anders@adamsgaard.dk wrote:
> Dear all,
> 
> Running awk from rc, I found that I need to quote the arguments to awk's
> -v option, as in:
> 
> 	awk -v 'myvar=asdf' 'BEGIN{print myvar}'
> 
> However, the awk man page specifies this without quotes as "awk -v
> myvar=asdf".  I now realize that it will not work without quotes because
> rc tries to interpret the assignment operator.
> 
> Is this just a beginner mistake, being used to unix behavior, or worth
> documenting as in the patch below?
> 
> Thanks, Anders

Hi,

awk(1)'s manpage seems mostly unchanged from unix.  I'm not sure it
makes sense to add quotes there since it's an rc specificity, not awk.
Perhaps a sentence could be added in the BUGS section?  Just my 2c.

Thanks!
qwx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 12:10 [9front] [PATCH] awk(1): quote argument for -v option Anders Damsgaard
  2022-11-29 13:47 ` qwx
@ 2022-11-29 14:52 ` Stanley Lieber
  2022-11-29 15:14 ` Kurt H Maier
  2 siblings, 0 replies; 10+ messages in thread
From: Stanley Lieber @ 2022-11-29 14:52 UTC (permalink / raw)
  To: 9front

this is an rc quirk, not related to awk. for example, what if you run awk from the ape/sh (or some other) shell?

on the other hand, obviously in almost every case the user will be launching awk from rc.

still, i do not think we need to document rc quoting behavior in every man page because ultimately the man page is for the program in question, while rc quoting is something a 9front user will have to come to terms with early in their career as a 9front.

in summary, rc’s quoting is not a universal condition, so it should remain implied rather than explicit in man pages that are not the rc man page.

sl

> On Nov 29, 2022, at 7:11 AM, Anders Damsgaard <anders@adamsgaard.dk> wrote:
> 
> Dear all,
> 
> Running awk from rc, I found that I need to quote the arguments to awk's
> -v option, as in:
> 
>    awk -v 'myvar=asdf' 'BEGIN{print myvar}'
> 
> However, the awk man page specifies this without quotes as "awk -v
> myvar=asdf".  I now realize that it will not work without quotes because
> rc tries to interpret the assignment operator.
> 
> Is this just a beginner mistake, being used to unix behavior, or worth
> documenting as in the patch below?
> 
> Thanks, Anders
> 
> 
> diff ff2ebe6cfdacd890a74a6d2f9b0acd062d2633b7 uncommitted
> --- a/sys/man/1/awk
> +++ b/sys/man/1/awk
> @@ -23,7 +23,7 @@
> ]
> [
> .B -v
> -.I var=value
> +.I 'var=value'
> ]
> [
> .B -f
> @@ -58,13 +58,13 @@
> Any
> .IR file
> of the form
> -.I var=value
> +.I 'var=value'
> is treated as an assignment, not a file name,
> and is executed at the time it would have been opened if it were a file name.
> The option
> .B -v
> followed by
> -.I var=value
> +.I 'var=value'
> is an assignment to be done before the program
> is executed;
> any number of
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 12:10 [9front] [PATCH] awk(1): quote argument for -v option Anders Damsgaard
  2022-11-29 13:47 ` qwx
  2022-11-29 14:52 ` Stanley Lieber
@ 2022-11-29 15:14 ` Kurt H Maier
  2022-11-29 15:22   ` Stanley Lieber
  2022-11-29 16:24   ` Sigrid Solveig Haflínudóttir
  2 siblings, 2 replies; 10+ messages in thread
From: Kurt H Maier @ 2022-11-29 15:14 UTC (permalink / raw)
  To: 9front

On Tue, Nov 29, 2022 at 01:10:26PM +0100, Anders Damsgaard wrote:
> Dear all,
> 
> Running awk from rc, I found that I need to quote the arguments to awk's
> -v option, as in:
> 
> 	awk -v 'myvar=asdf' 'BEGIN{print myvar}'
> 
> However, the awk man page specifies this without quotes as "awk -v
> myvar=asdf".  I now realize that it will not work without quotes because
> rc tries to interpret the assignment operator.
> 
> Is this just a beginner mistake, being used to unix behavior, or worth
> documenting as in the patch below?
> 
> Thanks, Anders

I guess I'll be that guy again

I know that the quoting quirk is a characteristic of rc and not whatever
other environment one might conceivably use to launch awk.  I get that
under most unix shells this is a non-issue.  However, the quoted variant
also works fine in e.g. bash and ksh and so forth.  It's all the same to
awk.

I submit as my actual argument that having documentation containing
examples which, when copied and pasted into the primary UI of the
project, do not work, is bad form.  People read man pages to learn how
to use shit, not to get a sense of the general aesthetic of a given
command were we to run it on v7 Unix.  The shit we say should work
should work.  

I vote the patch goes in.

khm

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 15:14 ` Kurt H Maier
@ 2022-11-29 15:22   ` Stanley Lieber
  2022-11-29 16:24   ` Sigrid Solveig Haflínudóttir
  1 sibling, 0 replies; 10+ messages in thread
From: Stanley Lieber @ 2022-11-29 15:22 UTC (permalink / raw)
  To: 9front


On Nov 29, 2022, at 10:17 AM, Kurt H Maier <khm@sciops.net> wrote:
> 
> I submit as my actual argument that having documentation containing
> examples which, when copied and pasted into the primary UI of the
> project, do not work, is bad form.  People read man pages to learn how
> to use shit, not to get a sense of the general aesthetic of a given
> command were we to run it on v7 Unix.  The shit we say should work
> should work.  

the fact that both examples do indeed work in all known environments is an important point, and i agree with the above as well.

i rescind my objection.

sl

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 15:14 ` Kurt H Maier
  2022-11-29 15:22   ` Stanley Lieber
@ 2022-11-29 16:24   ` Sigrid Solveig Haflínudóttir
  2022-11-29 16:28     ` Jacob Moody
  1 sibling, 1 reply; 10+ messages in thread
From: Sigrid Solveig Haflínudóttir @ 2022-11-29 16:24 UTC (permalink / raw)
  To: 9front

Quoth Kurt H Maier <khm@sciops.net>:
> On Tue, Nov 29, 2022 at 01:10:26PM +0100, Anders Damsgaard wrote:
> > Dear all,
> > 
> > Running awk from rc, I found that I need to quote the arguments to awk's
> > -v option, as in:
> > 
> > 	awk -v 'myvar=asdf' 'BEGIN{print myvar}'
> > 
> > However, the awk man page specifies this without quotes as "awk -v
> > myvar=asdf".  I now realize that it will not work without quotes because
> > rc tries to interpret the assignment operator.
> > 
> > Is this just a beginner mistake, being used to unix behavior, or worth
> > documenting as in the patch below?
> > 
> > Thanks, Anders
> 
> I guess I'll be that guy again
> 
> I know that the quoting quirk is a characteristic of rc and not whatever
> other environment one might conceivably use to launch awk.  I get that
> under most unix shells this is a non-issue.  However, the quoted variant
> also works fine in e.g. bash and ksh and so forth.  It's all the same to
> awk.
> 
> I submit as my actual argument that having documentation containing
> examples which, when copied and pasted into the primary UI of the
> project, do not work, is bad form.  People read man pages to learn how
> to use shit, not to get a sense of the general aesthetic of a given
> command were we to run it on v7 Unix.  The shit we say should work
> should work.  
> 
> I vote the patch goes in.
> 
> khm

Wasn't there a patch somewhere for Plan 9 Port(??) that made the
quoting a bit more relaxed when NOT specifying env vars?  I'd be more
inclined to accept non-quoted variant in parameters.  Having to quote
those is annoying, I want the computer to figure out what I'm doing,
not to baby-sit rc.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 16:24   ` Sigrid Solveig Haflínudóttir
@ 2022-11-29 16:28     ` Jacob Moody
  2022-11-29 16:43       ` Kurt H Maier
  0 siblings, 1 reply; 10+ messages in thread
From: Jacob Moody @ 2022-11-29 16:28 UTC (permalink / raw)
  To: 9front

On 11/29/22 09:24, Sigrid Solveig Haflínudóttir wrote:
> Quoth Kurt H Maier <khm@sciops.net>:
>> On Tue, Nov 29, 2022 at 01:10:26PM +0100, Anders Damsgaard wrote:
>>> Dear all,
>>>
>>> Running awk from rc, I found that I need to quote the arguments to awk's
>>> -v option, as in:
>>>
>>> 	awk -v 'myvar=asdf' 'BEGIN{print myvar}'
>>>
>>> However, the awk man page specifies this without quotes as "awk -v
>>> myvar=asdf".  I now realize that it will not work without quotes because
>>> rc tries to interpret the assignment operator.
>>>
>>> Is this just a beginner mistake, being used to unix behavior, or worth
>>> documenting as in the patch below?
>>>
>>> Thanks, Anders
>>
>> I guess I'll be that guy again
>>
>> I know that the quoting quirk is a characteristic of rc and not whatever
>> other environment one might conceivably use to launch awk.  I get that
>> under most unix shells this is a non-issue.  However, the quoted variant
>> also works fine in e.g. bash and ksh and so forth.  It's all the same to
>> awk.
>>
>> I submit as my actual argument that having documentation containing
>> examples which, when copied and pasted into the primary UI of the
>> project, do not work, is bad form.  People read man pages to learn how
>> to use shit, not to get a sense of the general aesthetic of a given
>> command were we to run it on v7 Unix.  The shit we say should work
>> should work.  
>>
>> I vote the patch goes in.
>>
>> khm
> 
> Wasn't there a patch somewhere for Plan 9 Port(??) that made the
> quoting a bit more relaxed when NOT specifying env vars?  I'd be more
> inclined to accept non-quoted variant in parameters.  Having to quote
> those is annoying, I want the computer to figure out what I'm doing,
> not to baby-sit rc.
> 


That there was, I believe it came with the work that was done in rewriting
the parser away from yacc. I would second this change.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 16:28     ` Jacob Moody
@ 2022-11-29 16:43       ` Kurt H Maier
  2022-11-29 19:06         ` Stanley Lieber
  0 siblings, 1 reply; 10+ messages in thread
From: Kurt H Maier @ 2022-11-29 16:43 UTC (permalink / raw)
  To: 9front

On Tue, Nov 29, 2022 at 09:28:04AM -0700, Jacob Moody wrote:
> On 11/29/22 09:24, Sigrid Solveig Hafl�nud�ttir wrote:
> > Quoth Kurt H Maier <khm@sciops.net>:
> >> On Tue, Nov 29, 2022 at 01:10:26PM +0100, Anders Damsgaard wrote:
> >>> Dear all,
> >>>
> >>> Running awk from rc, I found that I need to quote the arguments to awk's
> >>> -v option, as in:
> >>>
> >>> 	awk -v 'myvar=asdf' 'BEGIN{print myvar}'
> >>>
> >>> However, the awk man page specifies this without quotes as "awk -v
> >>> myvar=asdf".  I now realize that it will not work without quotes because
> >>> rc tries to interpret the assignment operator.
> >>>
> >>> Is this just a beginner mistake, being used to unix behavior, or worth
> >>> documenting as in the patch below?
> >>>
> >>> Thanks, Anders
> >>
> >> I guess I'll be that guy again
> >>
> >> I know that the quoting quirk is a characteristic of rc and not whatever
> >> other environment one might conceivably use to launch awk.  I get that
> >> under most unix shells this is a non-issue.  However, the quoted variant
> >> also works fine in e.g. bash and ksh and so forth.  It's all the same to
> >> awk.
> >>
> >> I submit as my actual argument that having documentation containing
> >> examples which, when copied and pasted into the primary UI of the
> >> project, do not work, is bad form.  People read man pages to learn how
> >> to use shit, not to get a sense of the general aesthetic of a given
> >> command were we to run it on v7 Unix.  The shit we say should work
> >> should work.  
> >>
> >> I vote the patch goes in.
> >>
> >> khm
> > 
> > Wasn't there a patch somewhere for Plan 9 Port(??) that made the
> > quoting a bit more relaxed when NOT specifying env vars?  I'd be more
> > inclined to accept non-quoted variant in parameters.  Having to quote
> > those is annoying, I want the computer to figure out what I'm doing,
> > not to baby-sit rc.
> > 
> 
> 
> That there was, I believe it came with the work that was done in rewriting
> the parser away from yacc. I would second this change.
> 

previously discussed in the thread 'new rc parser: do we want it?' in
this mailing list.

also related: https://www.mail-archive.com/9fans@9fans.net/msg36493.html

khm

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 16:43       ` Kurt H Maier
@ 2022-11-29 19:06         ` Stanley Lieber
  2022-11-29 19:52           ` Stanley Lieber
  0 siblings, 1 reply; 10+ messages in thread
From: Stanley Lieber @ 2022-11-29 19:06 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: image0.jpeg --]
[-- Type: image/jpeg, Size: 1478691 bytes --]

[-- Attachment #2: Type: text/plain, Size: 3 bytes --]

> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9front] [PATCH] awk(1): quote argument for -v option
  2022-11-29 19:06         ` Stanley Lieber
@ 2022-11-29 19:52           ` Stanley Lieber
  0 siblings, 0 replies; 10+ messages in thread
From: Stanley Lieber @ 2022-11-29 19:52 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

i just realized my last post may have come off as some kind of “don’t touch the artwork” statement, which was not my intention. i happen to be standing in a museum with several pieces of auk artwork right in front of me, and enjoyed the synchronicity.

sl


[-- Attachment #2: image0.jpeg --]
[-- Type: image/jpeg, Size: 1551255 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-29 19:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 12:10 [9front] [PATCH] awk(1): quote argument for -v option Anders Damsgaard
2022-11-29 13:47 ` qwx
2022-11-29 14:52 ` Stanley Lieber
2022-11-29 15:14 ` Kurt H Maier
2022-11-29 15:22   ` Stanley Lieber
2022-11-29 16:24   ` Sigrid Solveig Haflínudóttir
2022-11-29 16:28     ` Jacob Moody
2022-11-29 16:43       ` Kurt H Maier
2022-11-29 19:06         ` Stanley Lieber
2022-11-29 19:52           ` Stanley Lieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).