gawk modified its command line argument

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 6
  • gawk-3.1.7-6.el6

Issue

  • gawk-3.1.7 modified its command line argument in RHEL6 whereas
    gawk-3.1.5 in RHEL 5 did not.

Resolution

# yum update gawk

Root Cause

the gawk utility did not copy variables from the command
line arguments. As a consequence, the variables were not accessible as intended.

Diagnostic Steps

  This behavior changed between gawk-3.1.5 and gawk-3.1.6.  gawk-3.1.5
  replaced the '=' after parsing the command line, whereas gawk-3.1.6
  doesn't.  Upstream gawk-4.0.0 copies the contents of argv when
  assigning variables specified on the command line.
e.g

- Run the following commands
  $ echo toto | awk -v myvar=foo '{system("/bin/sleep 100")}' &
  $ ps h -o args -p $!
  $ awk -v myvar foo {system("/bin/sleep 100")
"=" between "myvar" and "foo" is missing


This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments