[Top][All Lists]

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

Re: Syntax Question...

From: Patrick
Subject: Re: Syntax Question...
Date: Wed, 28 Mar 2012 18:26:02 -0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11

On 18.08.2011 12:44, Stephane CHAZELAS wrote:
2011-08-17, 08:24(-04), Greg Wooledge:
On Tue, Aug 16, 2011 at 03:41:19PM -0700, Linda Walsh wrote:
Ken Irving wrote:
Maybe this?
    today_snaps=( ${snap_prefix} )

   but as you mention, that will put them into an array....sorry "imprecise
terminology".... list for me is some number of objects in a string
separated by some

This is an extremely bad idea.  Legacy Bourne shell code from the
1980s kind of bad -- from the horrible days before we *had* arrays
in shells.  How are you going to handle filenames with spaces in them?
With newlines in them?  With commas in them?  With colons in them?  Tabs?
DEL characters?  Those are all valid in filenames.  Any delimiter you
can *put* in a shell string is also a valid character in a filename (or
at least in a pathname, which eliminates the possibility of using slash).

In this code:

today_snaps=( ${snap_prefix} )

With the default value of IFS in bash and without globbing
disabled, the problematic characters are SPC, TAB, NL, *, ?, [
and potentially more if you have extended globbing enabled.

I think this works! You're missing the context or something. "snap_prefix" is a shell glob pattern here, ending in *.

$ touch ' ' $'\t' $'\n' '*' '?' '['
$ snap_prefix=*                  # no glob happening here!
$ today_snaps=( ${snap_prefix} ) # glob happening here and
                                 # the results are assigned to the
                                 # elements of the today_snaps array
$ for e in "address@hidden"; do stat -c%N "$e"; done
` '

I don't see a problem...

reply via email to

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