bug-bash
[Top][All Lists]
Advanced

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

using the variable name, GROUPS, in a read list


From: Jim Meyering
Subject: using the variable name, GROUPS, in a read list
Date: Wed, 07 Mar 2012 16:54:14 +0100

FYI, if I attempt to read into the built-in array variable, GROUPS,
this doesn't work:

  $ bash -c 'while read GROUPS; do echo $GROUPS; done < /etc/passwd'|wc -l
  0

Comparing with dash, I see what the author expected, i.e.,
that the while loop iterates once per line in /etc/passwd:

  $ dash -c 'while read GROUPS; do echo $GROUPS; done < /etc/passwd'|wc -l
  57

With bash, I can work around that by first doing "unset GROUPS".

Is there a moral here, other than to avoid using special variable names?
Probably to prefer lower-case variable names.



reply via email to

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