bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Is it possible to @include an awk file whose filename is


From: arnold
Subject: Re: [bug-gawk] Is it possible to @include an awk file whose filename is stored in a variable?
Date: Sat, 10 Nov 2018 10:21:10 -0700
User-agent: Heirloom mailx 12.4 7/29/08

Peng Yu <address@hidden> wrote:

> I can not @include an awk file whose filename is stored in a variable.
> Is it possible? Thanks.
>
> $ cat f.awk
> function f() {
>   print "Hello World!"
> }
> $ awk -e 'x = "f.awk"; @include x; BEGIN{ f() }' < /dev/null
> awk: cmd. line:1: x = "f.awk"; @include x; BEGIN{ f() }
> awk: cmd. line:1:                       ^ syntax error
>
> -- 
> Regards,
> Peng

This isn't possible. Include files are processed before any code
starts executing, so no variables are set. As explained in the documentation,
you have to supply a filename as a double-quoted string.

Arnold



reply via email to

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