[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: When would awk issue a warning message about invalid options?
From: |
Arkadiusz Drabczyk |
Subject: |
Re: When would awk issue a warning message about invalid options? |
Date: |
Sun, 4 Oct 2020 20:32:08 +0200 |
On Sun, Oct 04, 2020 at 10:47:48AM -0600, arnold@skeeve.com wrote:
> In this case yes, as you demonstrated:
>
> > I find
> > this likely since this sentence immediately follows the list of all
> > options and because this doesn't issue any warnings:
> >
> > $ awk -P 'BEGIN { for (i = 0; i < ARGC; i++) print ARGV[i] }' --1 --oeue
> > awk
> > --1
> > --oeue
>
> This is because an on-the-command-line program automatically ends
> the search for options, whereas -f does not, since there may be
> additional -f options.
ok, thanks for confirmation and an additional explanation.
> > But in manpage it says:
> >
> > gawk [ POSIX or GNU style options ] -f program-file [ -- ] file ...
> > gawk [ POSIX or GNU style options ] [ -- ] program-text file ...
> >
> > as if 'program text' was actually referring to what is specified in
> > the command line.
>
> That is what it means. The man page and the manual are different
> documents and need not be 100% consistent in the use of terminology
> between them.
Hmm, I really thought they'd follow the same terminology. Good to know.
> > 2. Shouldn't it be mentioned in gawktexi.in that warning messages are
> > only issued in compatibility mode as already mentioned in the manpage?
> > It could say for example:
> >
> > "In compatibility mode, as long as program text has been supplied, any
> > other options are flagged as invalid with a warning message but are
> > otherwise ignored."
>
> That's probably a good idea.
ok, should I send a patch (I'm not sure if it makes sense for such
small change)?
> > 3. What's the difference between -P and -c? This does not issue any
> > warnings:
> >
> > $ awk -c -f ./argv --1 --oeue
> > awk
> > --1
> > --oeue
> >
> > even though it the manpage it says that -c and -P are doing almost the
> > same thing:
> >
> > -c
> > --traditional
> > Run in compatibility mode.
> >
> > -P
> > --posix
> > This turns on compatibility mode
>
> Read the full text of the paragraph associated with -P:
>
> This turns on compatibility mode, with the following additional
> restrictions:
>
> · \x escape sequences are not recognized.
>
> · Only space and tab act as field separators when FS is set to a
> single space, newline does not.
>
> · You cannot continue lines after ? and :.
>
> · The synonym func for the keyword function is not recognized.
>
> · The operators ** and **= cannot be used in place of ^ and ^=.
>
> That seems quite clear to me.
Sorry, I read it a couple of times and still don't get it. From my
understanding, both -c and -P enable compatibility mode. If anything,
it's -P that does not enable a pure compatibility mode but something
close to it and hence awk -P ... shouldn't fall under `In
compatibility mode' category, not the other way around. Can you
explain it please?
--
Arkadiusz Drabczyk <arkadiusz@drabczyk.org>