Re: BASH no longer does 'for i in $(ls); do ls $i; done'??

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



On 05/18/2010 03:58 PM, Aaron Griffin wrote:
> On Tue, May 18, 2010 at 3:47 PM, Sergey Manucharian
> <ingeniware@xxxxxxxxx> wrote:
>> Excerpts from Linas's message of Tue, 18 May 2010 22:31 +0200:
>>
>>> David C. Rankin wrote:
>>>> Guys,
>>>>
>>>>     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:
>>>>
>>>>
>>>>     What could keep the simple cli from working on Arch? I know
>>>> this stuff worked before updates this morning... What should I look
>>>> at?
>>> Bash was updated from 4.1.5(2) to 4.1.7(2).
>>> I can't reproduce it, though.
>>
>> I cannot reproduce it either and suspect that your "ls" under $() is
>> not the real ls, but an alias. I've played with some, and they indeed
>> produce bad output.
> 
> If this is the case, replace "ls" with "/bin/ls" in the above and try again
> 

01:28 nirvana:/home/backup/rpms/compiz_X11.0> for i in $(/bin/ls); do echo -e
"'ls ${i}'\n"; /bin/ls ${i}; done
'ls i586'

compiz-0.8.6-46.1.i586.rpm			  compiz-plugins-extra-devel-0.8.6-5.2.i586.rpm
<snip>

Wohoo! It works....

	So the bottom line is don't alias 'ls'. And, I guess, the next question would
be, how or where can I safely customize the behavior of ls without screwing
myself again. I had thought that setting a system wide alias for ls would be OK
by setting it in /etc/bash.bashrc.local. The contents were:

01:30 nirvana:/home/backup/rpms/compiz_X11.0> cat /etc/bash.bashrc.local.sav

alias ls='ls --color --group-directories-first'

	Just tinkering, here is what I've found. If I make the changes in ~/.bashrc,
the everything works fine, but if I make the same change in
/etc/bash.bashrc.local, then the problem occurs. If you want to re-create my
problem, just include the following alias:

alias ls='ls --color --group-directories-first'

in:

/etc/bash.bashrc.local

	Then find a simple directory and try to run:

for i in $(ls); do ls ${i}; done

	It will bomb. Then delete the alias from /etc/bash.bashrc.local and put the
'same' alias in your ~/.bashrc. The for loop works fine ... and ... you get the
customized 'ls' behavior.

	What I do not understand is why the difference whether you put the alias in
/etc/bash.bashrc.local or ~/.bashrc?

	

-- 
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
www.rankinlawfirm.com


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux