bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] syntax error when setting RS via string concatenation


From: Ed Morton
Subject: Re: [bug-gawk] syntax error when setting RS via string concatenation
Date: Mon, 9 May 2016 09:13:27 -0500
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0

and now so do I :-). thanks.


On 5/9/2016 8:41 AM, address@hidden wrote:
Andy's got it.

Thanks,

Arnold

"Andrew J. Schorr" <address@hidden> wrote:

On Mon, May 09, 2016 at 08:16:17AM -0500, Ed Morton wrote:
I didn't expect to get this syntax error when setting RS via string 
concatenation:

     $ awk 'BEGIN{RS="[x"; RS=RS"]"}'
     awk: cmd. line:1: fatal: Unmatched [, [^, [:, [., or [=: /[x/

as opposed to setting it to a variable constructed by the same string 
concatenation

     $ awk 'BEGIN{t="[x"; t=t"]"; RS=t}'
     $

Is that a bug or a feature (and if so, what feature?).
I think it's a feature. Consider this:

bash-4.2$ ./gawk 'BEGIN {RS = "[x"}'
gawk: cmd. line:1: fatal: Unmatched [, [^, [:, [., or [=: /[x/

Why should setting RS to an invalid regexp succeed? There is no way for gawk to
know that it should ignore RS because you plan to fix it later.

Your workaround using a temporary variable seems to be the
correct solution.

Regards,
Andy




reply via email to

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