From: twf_cc on
Dear All,

I have a problem with export gawk's enviroment var AWKPATH.
I have some function place in ~/lib/awk, after export AWKPATH
enviroment var, it is worked to call function from ~/lib/awk
here is screen shot
fang(a)bash ~
$ tail -n6 ~/.bash_profile
export NNTPSERVER='freenews.netfront.net'
export LYNX_CFG="$HOME/lynx.cfg"
export LESSCHARSET=latin1
#export LC_CTYPE=zh_CN.gbk
export CHARSET=GBK
export AWKPATH="/usr/lib/awk:$HOME/lib/awk"

fang(a)bash ~
$ unset AWKPATH

fang(a)bash ~
$ echo $AWKPATH


fang(a)bash ~
$ source .bash_profile

fang(a)bash ~
$ echo $AWKPATH
/usr/lib/awk:/home/fang/lib/awk

fang(a)bash ~
$ echo abcd | gawk -f reverse.awk --source '{print reverse($0)}'
dcba

fang(a)bash ~
$ cat junk
#! /bin/gawk -f reverse.awk --source
{
print reverse($0)
}

fang(a)bash ~
$ echo abcd | ./junk
gawk: fatal: can't open source file ` reverse.awk --source' for
reading (No such file or directory)

I got a error.....

calling gawk from shell

$ cat junk2
#! /bin/bash

gawk -f reverse.awk --source '{print reverse($0)}'

fang(a)bash ~
$ echo abcd |./junk2
dcba

there is no error message.

my platform and gawk version

fang(a)bash ~
$ uname -a
CYGWIN_NT-5.1 bash 1.5.25(0.156/4/2) 2008-03-05 19:27 i686 Cygwin

fang(a)bash ~
$ gawk --version | head -n2
GNU Awk 3.1.6
Copyright (C) 1989, 1991-2007 Free Software Foundation.

thanks.

rgd

twf
From: Barry Margolin on
In article
<e9782a23-f8af-4957-8801-9324e78470ff(a)s8g2000prg.googlegroups.com>,
twf_cc <twfccc(a)gmail.com> wrote:

> Dear All,
>
> I have a problem with export gawk's enviroment var AWKPATH.
> I have some function place in ~/lib/awk, after export AWKPATH
> enviroment var, it is worked to call function from ~/lib/awk
> here is screen shot
> fang(a)bash ~
> $ tail -n6 ~/.bash_profile
> export NNTPSERVER='freenews.netfront.net'
> export LYNX_CFG="$HOME/lynx.cfg"
> export LESSCHARSET=latin1
> #export LC_CTYPE=zh_CN.gbk
> export CHARSET=GBK
> export AWKPATH="/usr/lib/awk:$HOME/lib/awk"
>
> fang(a)bash ~
> $ unset AWKPATH
>
> fang(a)bash ~
> $ echo $AWKPATH
>
>
> fang(a)bash ~
> $ source .bash_profile
>
> fang(a)bash ~
> $ echo $AWKPATH
> /usr/lib/awk:/home/fang/lib/awk
>
> fang(a)bash ~
> $ echo abcd | gawk -f reverse.awk --source '{print reverse($0)}'
> dcba
>
> fang(a)bash ~
> $ cat junk
> #! /bin/gawk -f reverse.awk --source
> {
> print reverse($0)
> }
>
> fang(a)bash ~
> $ echo abcd | ./junk
> gawk: fatal: can't open source file ` reverse.awk --source' for
> reading (No such file or directory)
>
> I got a error.....'

The error doesn't seem to have anything to do with AWKPATH, it's with
the way the shebang line is processed. It's treating "reverse.awk
--source" as a single argument.

Most systems have limits on the number of arguments that can be used in
a shebang line. Apparently on your OS, everything after that is treated
as a single argument.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***