[arch-general] BASH no longer does 'for i in $(ls); do ls $i; done'??
David C. Rankin
drankinatty at suddenlinkmail.com
Wed May 19 02:51:15 EDT 2010
On 05/18/2010 03:23 PM, Daenyth Blank wrote:
> On Tue, May 18, 2010 at 16:17, David C. Rankin
> <drankinatty at suddenlinkmail.com> wrote:
>> I'm usually quite good at one-liners, but my simple ones no longer work in
>> Arch. Same cli works fine in suse. What have I messed up? To wit:
> In short, you're doing it wrong.
Yes, I agree with the article, but the concerns are limited to Internal File
Separator ($IFS) issues. If you properly handle $IFS issues, like:
OLDIFS=$IFS # (default is <space><tab><newline>: IFS=$' \t\n')
for i in $(ls); do echo "whatever $i"; done
IFS=$OLDIFS # not really required if run in a script because your present
# environment will be protected by execution in a subshell. If used
# as a one-liner, just enclose your cli in parenthesis for the
# same protection. i.e. '( your code )' forces your code to execute
# in a subshell.
In my instance:
01:13 alchemy:~/dt/compiz/compiz_11.0> l
drwxr-xr-x 6 david dcr 4096 2010-05-17 23:56 ./
drwxr-xr-x 9 david dcr 4096 2010-05-18 10:28 ../
drwxr-xr-x 2 david dcr 4096 2010-05-18 10:24 i586/
drwxr-xr-x 2 david dcr 4096 2010-05-17 23:56 noarch/
drwxr-xr-x 2 david dcr 4096 2010-05-18 10:22 src/
drwxr-xr-x 2 david dcr 4096 2010-05-18 10:21 x86_64/
I would still expect my original command line to work. Aaron and Sergey nailed
down where I messed up by putting my alias in /etc/bash.bashrc.local. Though I
still don't understand why having it in /etc/bash.bashrc.local instead of
~/.bashrc makes a difference.
That's what I need to learn. I'll poke around and report back if somebody
doesn't answer it first. That's something I want to understand.
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
More information about the arch-general