bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gawk manual correction. Option -v is more complex


From: arnold
Subject: Re: Gawk manual correction. Option -v is more complex
Date: Sun, 11 Dec 2022 12:58:37 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Hello.

Thank you for your mail. Please see the manual on bug reports
(https://www.gnu.org/software/gawk/manual/gawk.html#Bugs)
for any future reports. In particular, there's no need to send
mail to gnu@gnu.org or to me directly, as I get all mail sent
to the bug list.

Also, formatting your email with paragraph breaks would help a lot.
Below, I have reformatted it so that I could understand what
you were trying to convey. If it was formatted nicely when you
sent it, then your mailer mangled it somehow.

In response to what you write, I believe that everything is already
covered in the manual. In particular, see 2.3 "Other Command Line Arguments"
(https://www.gnu.org/software/gawk/manual/gawk.html#Other-Arguments)
and also 6.1.3.2 "Assigning Variables on the Command Line"
(https://www.gnu.org/software/gawk/manual/gawk.html#Assignment-Options).

Thanks,

Arnold

Youni Git <git@youni.world> wrote:

> Hello,  dear GNU!
> 
> I have a request to improve the manual of Gnu awk gawk. In last version
> of October, 2022, there is an explanation of command line option "-v":-v
> var=valĀ --assign var=valĀ [ .... quote of manual omitted .. ]
> 
> I tested, and got extremely another result, that must be described in
> the manual.
> 
> 1. There is a difference, where exactly in command line option -v
> appears. If program text or file appears before definition of variable,
> this variable cannot be used in BEGIN rule. Awk reads the command line
> like a code and runs it as a sequence of commands and data. This is
> fundamental.
> 
> 2. Variable can vary for every file used, when another value is placed
> before another file. Awk reads and set the new value of variable if
> provided before processing of file defined after new variable.Example:
> 
> $ echo text1 > file1
> $ echo text2 > file2
> $ echo 'BEGIN {print "at the beginning myvar is " myvar};
> {print "myvar is " myvar, ", text is " $0};
> END {print "in the end myvar is " myvar};' > program.awk
> $ awk -f program.awk myvar=kuku file1 myvar=auau file2
> 
> at the beginning myvar ismyvar is kuku , text is text1 myvar is auau ,
> text is text2 in the end myvar is auau. Awk reads, uses and process the
> command line arguments in a sequence as like it is a code. Awk runs the
> program file program.awk before variable myvar is set, because actually
> variable is provided after program file is provided in command line.
> Myvar is not set before running the code in BEGIN rule. And myvar
> is changing after file1 was processed. In section END myvar has its
> last value. I hope such example will be useful and will save time
> of programmers reading manual and writing first awk programs with
> variables. I think it is fundamental feature to set variable before
> processing of each file, and it must be considered in the manual.
> 
> $ awk -VGNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.0)Copyright
> (C) 1989, 1991-2020 Free Software Foundation.
> 
> Best regards.
> 
> Youni.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]