bug-bash
[Top][All Lists]
Advanced

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

Re: Bash 2.05a isn't calling gawk as expected


From: Bob Proulx
Subject: Re: Bash 2.05a isn't calling gawk as expected
Date: Wed, 7 Nov 2007 11:42:59 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

nparks@torah.org wrote:
>   A shell script which worked perfectly using "1.14.7(1)" fails to execute
> properly using "2.05a.0(1)-release".  The purpose of the script is to parse
> a session log file found in each user's home directory, and determine
> whether a record belonging to some other user appears with today's date in
> the file.
>   The parsing is done by gawk, using variables passed to it by repeated use
> of the "-v" parameter.

Thanks for the report.  Unfortunately your test case is too
complicated to recreate easily and also unfortunately incomplete since
the contents of the input file are never specified.  Without knowing
that information it can't be duplicated.

>   I have tried this with both gawk 3.0.6 and gawk 3.1.1, and I get the same
> results with either gawk.  When I use bash 1.14, bash calls gawk correctly
> and gives it the proper parameters.  When I use bash 2.05a, each invocation
> of gawk produces an error msg saying that gawk cannot open a file named
> "-v".

Then the command line for awk or the environment is probably different
in those two cases.  Please look specifically at the command line
given to awk and then to the environment (specifically any locale
setttings) for differences.

>   Create files named "session_log" in the home directories of some users,
> and run the script.

What the test case really needs is something that other people can
recreate on their systems to reproduce the problem.  That means that
hard coded paths (other than /tmp) are bad.

> blockflag=/ihome/tables/modemhog.txt
> pageflag=/ihome/tables/modemhog.page
> for i in /home/*

Also all of the input needs to be included.

>   tail session_log |

What is in session_log?

>     gawk -v Username=`basename $i` -v TodayDate=`date '+%b %e'` \

Using date like that looks to be trouble.

  $ date '+%b %e'
  Nov  7

Is that your problem?

>       -v CurrentYear=`date '+%Y'` -v BlockFlag=$blockflag \
>       '$0 ~ /[Uu]ser/ && $0 !~ Username && $0 ~ TodayDate \
>       && $0 ~ CurrentYear \
>       {print Username, $0 >> BlockFlag}'  

Please try to create a smaller test case.  Something like this:

  echo "User foo 2007-11-07" |
  awk -v Username=bob -v TodayDate=2007-11-07 \
    '$0 ~ /[Uu]ser/ && $0 !~ Username && $0 ~ TodayDate {print Username, $0}'
  bob User foo 2007-11-07

Then the test case will be self-contained and other people can
reproduce it.

Thanks
Bob




reply via email to

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