[Top][All Lists]

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

Re: Puzzling discrepancy in bash variables

From: Matthew Woehlke
Subject: Re: Puzzling discrepancy in bash variables
Date: Wed, 15 Oct 2008 19:08:46 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20080723 Fedora/ Thunderbird/ Mnenhy/

RMMM wrote:
RMMM wrote:
As far as I can tell, the variables $filenames and $filenames1 have the
same values. Yet, they behave differently when used in an argument. Is there some hidden aspect to a bash variable that I'm not seeing?

I just figured out the problem. I was running this in a shell with
dircolors. Arggg!

doing filenames=`ls --color=no mydir`
is all I needed to do. Well ... maybe there's some better way of getting the
that's immune to any invisible codes.

Guess 1:
command ls # avoids aliases, I think?
\ls # similar
env ls # also similar

(note: I belive --color=no is default behavior, probably you have an alias that is adding --color=auto / --color=tty, which is why avoiding the alias should work)

Guess 2:
files="$( for f in mydir/* ; do echo -n "${f#mydir/} " ; done )"
# uses bash glob expansion instead of ls, probably faster to boot

Guess 3:
files="$( cd mydir ; echo * )"

Please do not quote my e-mail address unobfuscated in message bodies.
Time is an illusion. Lunchtime doubly so. -- Ford Prefect (Douglas Adams' HHGttG)

reply via email to

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