bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Debugging Script


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Debugging Script
Date: Mon, 8 Apr 2019 11:47:02 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Sat, Apr 06, 2019 at 08:13:00PM +0200, Holger Klene wrote:
> I had to learn the hard way, that debugging requires a script file [1].
> 
> So I tried being clever and thought I run this in bash:
> 
> $ printf "%s\n" a b c \
>  | gawk -f <(echo '{ if ($1 == "b") { print "great" } }')
> 
> From bash man page [2]:
> > Process substitution allows a process's input or output to be referred
> to using a filename.
> 
> Well so far it works great. But on adding -D to start debugging, I get
> an error requesting option -f ... somehow gawk caught me cheating :-(

What exactly happens? When I try it, I don't get an error, but it's 
clearly not ideal:

bash-4.2$ ./gawk -D -f <(echo '{ if ($1 == "b") { print FILENAME, "great" } }')
gawk> list
error: can't open source file `/dev/fd/63' for reading (No such file or 
directory)

As you can see, it's a bit problematic for the debugger not to have access
to an actual source file.

> Now I have to "enhance" my bash-script to write a temp file at runtime.
> This way I can keep my awk script (< 20 lines) embedded in context with
> the surrounding bash script. But the necessary code looks really ugly
> and in addition, I cannot easily toggle a comment somewhere to switch
> off debugging *AND* writing the file at the same time.
> 
> My questions:
> a) I don't get where my error is? Why doesn't my "workaround" just work?

How is it failing?

> b) Is there a bug tracker on this known limitation [1]? What's the plan?
> Somebody working on it? ETA? How hard can it be to keep a few lines of
> script in memory?

I'm not aware of any bug tracker. This sounds more like a feature request
to me...

Regards,
Andy



reply via email to

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