help-gawk
[Top][All Lists]
Advanced

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

Re: Will @include be called multiple times for duplicated files?


From: Peng Yu
Subject: Re: Will @include be called multiple times for duplicated files?
Date: Sun, 26 Feb 2023 13:15:00 -0600

On 2/26/23, Manuel Collado <mcollado2011@gmail.com> wrote:
> El 26/02/2023 a las 4:24, Peng Yu escribió:
>> https://www.gnu.org/software/gawk/manual/html_node/Include-Files.html
>>
>> Where does it answer my question?
>
> 1.- The gawk manual:
> https://www.gnu.org/software/gawk/manual/html_node/Options.html
>
> -i source-file
> --include source-file
>
>      Read an awk source library from source-file. This option is
> completely equivalent to using the @include directive inside your

This is an oxymoron. The manual should not be written as "completely
equivalent" and then say it is different. At most, it can say
"similar" than explain the difference.

It seems that the manual has quite some room to be improved.

> program. It is very similar to the -f option, but there are two
> important differences. First, when -i is used, the program source is not
> loaded if it has been previously loaded, whereas with -f, gawk always
> loads the file. ...
>
> 2.- The man page: "man gawk"
>
> OPTIONS
> ...
>      -i include-file, --include include-file
>          Load  an awk source library.  This searches for the library
>          using the AWKPATH environment variable.  If the initial search
>          fails, another attempt will be made after appending the .awk
>          suffix.  The file will be loaded only once (i.e., duplicates are
>          eliminated), ...
> ...
> AWK PROGRAM EXECUTION
> ...
>         In addition, lines beginning with @include may be used to include
>         other source files  into your program.  This is equivalent to
>         using the --include option.
>
> Does this answer your question?

Yes.

However, the manual of awk seems to be out of place. The document of
@include should be in the section discussing @include instead of in
the section of -i.

>> On 2/25/23, Manuel Collado <mcollado2011@gmail.com> wrote:
>>> Please read the gawk manual before asking. Hint: @include and --include.
>>>
>>> El 25/2/23 a las 2:04, Peng Yu escribió:
>>>> Suppose that A.awk includes B.awk, C.awk includes B.awk, D.awk
>>>> includes A.awk and C.awk, if I include D.awk in another awk file, how
>>>> many times B.awk will be accessed by awk? Is it twice or once?
>>>>
>>>> In other words, does awk know B.awk has been included already and
>>>> therefore will not try to include it again?
>>>>
>>> --
>>> Manuel Collado - http://mcollado.z15.es
>
> --
> Manuel Collado - http://mcollado.z15.es
>
>


-- 
Regards,
Peng



reply via email to

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