Re: Rewriting a shell script

From: Colin Booth <cathexis_at_gmail.com>
Date: Mon, 30 Nov 2015 08:57:16 -0800

On Mon, Nov 30, 2015 at 12:14 AM, Laurent Bercot
<ska-skaware_at_skarnet.org> wrote:
> Hm ? I don't think awk understand delimiters at all. It only
> takes a single argument (in this case). The quotes are a shell
> thing.
>
Delimiters was the wrong word. I was poorly trying to say that it
wanted its script as a single element.
>
>> define -sn B ${A} does essentially the same thing as awk '{print $1}'.
>
> Not at all, if ${A} contains whitespace! ${B} will then expand to
> several words, but you only want the first one.

Eh what? define -sn splits ${A} into N words, of which the first is
put into ${B} and the rest dropped. Actually, on further testing, it
looks like what's happening is that -n throws away the last item in
non-newline terminated values. For example:
---
$ execlineb -c 'define B "a b c" define -sn A ${B} echo ${A}'
a b
---
Not sure if that's intentional, but it's definitely not what the
documents say is supposed to happen. My confusion was because -n was
throwing away the last delimiter, along with the hostname after it.
That also explains why chomping doesn't do that on newline terminated
values, it still has something legal to toss.
Cheers!
-- 
"If the doors of perception were cleansed every thing would appear to
man as it is, infinite. For man has closed himself up, till he sees
all things thru' narrow chinks of his cavern."
  --  William Blake
Received on Mon Nov 30 2015 - 16:57:16 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC