help-gawk
[Top][All Lists]
Advanced

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

Re: inconstancy with RS = "(\r?\n){2}"


From: Alex fxmbsw7 Ratchev
Subject: Re: inconstancy with RS = "(\r?\n){2}"
Date: Sat, 24 Jul 2021 16:54:01 +0200

this is a re post to the list also

no, only bit cgi, more.. a minimal small ( public domain open source )
complete httpd ( that serves http requests ) in bash and gawk

i have also successfully a modular files system that loads bash code
generated by gawk by files
hard to say

anyway this is httpd.gawk here in case

in short what i experience with RS (\r?\n){2} same as \r?\n\r?\n
is it never returns, not valid

do on terminal, not pipe, gawk -v RS='(\r?\n){2}' -v ORS= '1'
then enter 'abc' and a couple of newlines via enter key
it never prints
...

no eof pipe, non ending terminal or socket input

if you got interest in either, the httpd gawk or some modular
bash-from-files loader, i can post

On Sat, Jul 24, 2021 at 4:45 PM Wolfgang Laun <wolfgang.laun@gmail.com> wrote:
>
> Are you trying to implement a CGI script?
> -W
>
> On Sat, 24 Jul 2021 at 16:41, Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
>>
>> i found it nice to have RS \0\0 and FS \0
>> same with newlines
>> but shitty i have to deal with optional \r's
>> so shittier i came axross this gawk bug ( now clear ? with terminal non eof 
>> input, manual ) long time to figure why stuff doesnt return anything
>>
>> On Sat, Jul 24, 2021, 16:30 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
>>>
>>> no pipe with eof, run my your small gawk with 1 { print } like you did but 
>>> no pipe, terminal input ( cause most http clients dont end connection after 
>>> request etc )
>>> then enter, abc, then a couple enter newlines
>>> it never prints
>>>
>>> On Sat, Jul 24, 2021, 16:16 Wolfgang Laun <wolfgang.laun@gmail.com> wrote:
>>>>
>>>> Setting RS = "(\r?\n){2}" (as in your original command gawk -v 
>>>> RS="(\r?\n){2}" 1) works for me. Here is the shell script I run and the 
>>>> output:
>>>>
>>>> echo -e -n "line1a\nline1b\n\nline2\n\nX\n\nX\n\nline5\nline6\n\n" | \
>>>> sed -e 's/X//' | \
>>>> gawk -v RS="(\\r?\\n){2}" '{print}'
>>>>
>>>> /tmp$ ./doublers.sh
>>>> line1a
>>>> line1b
>>>> line2
>>>>
>>>>
>>>> line5
>>>> line6
>>>> /tmp$
>>>>
>>>> Perhaps you comment on this: what does not work? Or show another input 
>>>> sequence that illustrates the problem.
>>>>
>>>> -W
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Sat, 24 Jul 2021 at 15:16, Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> 
>>>> wrote:
>>>>>
>>>>> i removed all my stdbuf screen wrapper stuff, still same gawk behavior
>>>>>
>>>>> On Sat, Jul 24, 2021, 15:12 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> 
>>>>> wrote:
>>>>>>
>>>>>> instead of RS and FS ? no chance
>>>>>> then its a sloppy gawk bug
>>>>>>
>>>>>> i added your code to a script, with RS = .., same no output
>>>>>>
>>>>>> gawk -v RS='\r?\n\r?\n' 1
>>>>>> a
>>>>>> b
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ..never shows anything, till special other data input
>>>>>>
>>>>>> On Sat, Jul 24, 2021 at 3:08 PM Wolfgang Laun <wolfgang.laun@gmail.com> 
>>>>>> wrote:
>>>>>> >
>>>>>> > If you want to print some output immediately after two empty input 
>>>>>> > lines you should better add these two rules:
>>>>>> > length($0) == 0 {
>>>>>> >      if( ++empty == 2 ){ print "two!!"; empty = 0; }
>>>>>> > }
>>>>>> > length($0) > 0 { empty = 0; }
>>>>>> >
>>>>>> > /tmp$ gawk -f doublers.awk
>>>>>> > line 1
>>>>>> > line 2
>>>>>> > <empty line>
>>>>>> > line 3
>>>>>> > <empty line>
>>>>>> > <empty line>
>>>>>> > two!!
>>>>>> > line 4
>>>>>> > <empty line>
>>>>>> > line 5
>>>>>> > line 6
>>>>>> > <empty line>
>>>>>> > <empty line>
>>>>>> > two!!
>>>>>> > line 7
>>>>>> > wlaun@terra:/tmp$
>>>>>> >
>>>>>> > -W
>>>>>> >
>>>>>> > On Sat, 24 Jul 2021 at 14:14, Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> 
>>>>>> > wrote:
>>>>>> >>
>>>>>> >> i dont have such coloring, the input is 'foo\nbar\n\n\n\n..none\n'
>>>>>> >> then it prints the first time, then two control-d's or three are
>>>>>> >> needed to print the rest and end
>>>>>> >> ..
>>>>>> >>
>>>>>> >> gawk -v RS='(\r?\n){2}' -v ORS= '{ print "-" NR, $0, RT }'
>>>>>> >>
>>>>>> >> foo
>>>>>> >> bar
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> >> none
>>>>>> >> -1 foo
>>>>>> >> bar
>>>>>> >>
>>>>>> >> -2
>>>>>> >>
>>>>>> >> -3
>>>>>> >>
>>>>>> >> -4
>>>>>> >> none
>>>>>> >>
>>>>>> >>
>>>>>> >> On Sat, Jul 24, 2021 at 7:28 AM Wolfgang Laun 
>>>>>> >> <wolfgang.laun@gmail.com> wrote:
>>>>>> >> >
>>>>>> >> > I'm not sure what you did to demonstrate that this setting does not 
>>>>>> >> > work. But this is the awk program I tried:
>>>>>> >> >    BEGIN { RS="(\r?\n){2}" }
>>>>>> >> >    NR % 2 == 1 { print NR " " $0; }
>>>>>> >> > and this is how I ran it (using 5.1.0), program output shown with a 
>>>>>> >> > green background:
>>>>>> >> > /tmp$ gawk -f doublers.awk
>>>>>> >> > abc
>>>>>> >> > def
>>>>>> >> >
>>>>>> >> > ghi
>>>>>> >> > jkl
>>>>>> >> > 1 abc
>>>>>> >> > def
>>>>>> >> >
>>>>>> >> > mno
>>>>>> >> > pqr
>>>>>> >> >
>>>>>> >> > stu
>>>>>> >> > vwx
>>>>>> >> > 3 mno
>>>>>> >> > pqr
>>>>>> >> > /tmp$
>>>>>> >> >
>>>>>> >> > HTH
>>>>>> >> > -W
>>>>>> >> >
>>>>>> >> > On Sat, 24 Jul 2021 at 04:39, Alex fxmbsw7 Ratchev 
>>>>>> >> > <fxmbsw7@gmail.com> wrote:
>>>>>> >> >>
>>>>>> >> >> i tried this in my httpd project, but it doesnt result anything
>>>>>> >> >>
>>>>>> >> >> gawk -v RS="(\r?\n){2}" 1
>>>>>> >> >>
>>>>>> >> >> two enters it doesnt catch also
>>>>>> >> >>
>>>>>> >> >> it when entered some data sometimes needs multiple control d s to 
>>>>>> >> >> proceed \
>>>>>> >> >> end
>>>>>> >> >
>>>>>> >> >
>>>>>> >> >
>>>>>> >> > --
>>>>>> >> > Wolfgang Laun
>>>>>> >> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > --
>>>>>> > Wolfgang Laun
>>>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Wolfgang Laun
>>>>
>
>
> --
> Wolfgang Laun
>



reply via email to

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