[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk cannot control the use of interval expressions from within a pr
From: |
Stephane Chazelas |
Subject: |
Re: gawk cannot control the use of interval expressions from within a program |
Date: |
Sun, 7 Nov 2004 19:27:51 +0000 |
User-agent: |
Mutt/1.5.6i |
On Sun, Nov 07, 2004 at 11:49:18AM -0700, Bob Proulx wrote:
> Hello Stéphane,
> (offlist)
>
> Stephane Chazelas wrote:
> > You can do it as:
> >
> > #! /bin/sh -
> > ":" +0 && "exec" "/usr/bin/gawk" "-Wre-interval" "-f" "$0"
> >
> > <Your gawk script goes here>
>
> I am not familiar with some of the constructs so I did not respond to
> the list. But that needs to be "$@" or ${1+"$@"} in the above use of
> "$0", right?
You're right, I forgot about the arguments, it should be:
":" +0 && "eval" "exec /usr/bin/gawk -Wre-interval -f \"\$0\"
\${1+\"address@hidden"}"
> I am curious about two of the constructs you used.
>
> 1. #!/bin/sh -
>
> Why the "-" in the option list?
Same thing as in rm -- "$file", if $file starts with a "-", you
get unexpected behavior if you forget the "--". Here, if the name
of the script (as given as the first argument to execve(2))
starts with "-", you will also get an error.
> That does not seem portable to
> me. What effect is desired there.
It is supposed to be portable, it worked already with the first
release of the Bourne shell
>
> 2. : +0
>
> What effect is desired there? This would seem to me to always be
> true. Of course we are feeding this to awk as stdin. But what is
> it going to be doing there?
":" +0
expands to 0 (hence "false") in awk and to true (the ":" noop
command returns a 0 exit status) in shell.
That line is supposed to be interpreted by the shell, and not by
awk.
> 3. I am assuming that you are quoting everything so that awk will
> parse it correctly?
That's right.
regards,
Stéphane