[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
When would awk issue a warning message about invalid options?
From: |
Arkadiusz Drabczyk |
Subject: |
When would awk issue a warning message about invalid options? |
Date: |
Sun, 4 Oct 2020 15:13:55 +0200 |
In gawktexi.in it says:
"As long as program text has been supplied, any other options are
flagged as invalid with a warning message but are otherwise ignored."
And in the manpage it says:
"In compatibility mode, any other options are flagged as invalid, but
are otherwise ignored. In normal operation, as long as program text
has been supplied, unknown options are passed on to the AWK program in
the ARGV array for processing. This is particularly useful for
running AWK programs via the #! executable interpreter mechanism."
But I'm having a hard trying to understand in what situations would
awk actually issue a warning message about invalid options.
By some trials and errors I figured out it would if I did this:
$ awk -P -f ./argv --1 --oeue
awk: unrecognized option '--1'
awk: unrecognized option '--oeue'
awk
where ./argv is:
BEGIN { for (i = 0; i < ARGC; i++) print ARGV[i] }
But it's still very unclear:
1. Does 'program text' in gawktexi.in refer only to -f option? 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
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.
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."
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
--
Arkadiusz Drabczyk <arkadiusz@drabczyk.org>
- When would awk issue a warning message about invalid options?,
Arkadiusz Drabczyk <=