It is currently Tue, 30 Nov 2021 18:22:15 GMT



 
Author Message
 Question on order of filename expansion of {a,b}/{c,d} in bash (or csh)
Suppose you do: ls /foo/bar/{a,b}/{c,d}
(for suitable values of a,b,c, and d)
What is the order of the output?  Is it guaranteed?

I've found that I get:

    /foo/bar/a/c
    /foo/bar/a/d
    /foo/bar/b/c
    /foo/bar/b/d

which, as it happens, is what I want, but I was wondering about the
ambiguity of it.  I am working, primarily, under bash (1.14).

Note that it would be possible for it to expand as:

    /foo/bar/a/c
    /foo/bar/b/c
    /foo/bar/a/d
    /foo/bar/b/d

And, although I can't replicate it now, I was sure that: /foo/bar/[ab]/{c,d}
did, in fact, expand the other way.



 Sat, 14 Apr 2007 08:30:56 GMT   
 Question on order of filename expansion of {a,b}/{c,d} in bash (or csh)

That's because {} is expanded before [].  In fact, brace expansion is
the first thing that is done.  So, it becomes
    /foo/bar/[ab]/c
    /foo/bar/[ab]/d
--
William Park <opengeome...@yahoo.ca>
Open Geometry Consulting, Toronto, Canada



 Sat, 14 Apr 2007 09:15:38 GMT   
 Question on order of filename expansion of {a,b}/{c,d} in bash (or csh)
2004-10-26, 00:30(+00), Kenny McCormack:
[...]

{a,b} is not filename expansion, it does expand wether there are
files by those names or not, they are not related to files in
any way.

For instance, in zsh:

echo {/usr,}/bin/*.sh

is expanded to:

echo /usr/bin/*.sh /bin/*.sh
(I can't imagine how it could be done the other way round).

so will fail with a "no match" error if there's no *.sh files in
/bin even though there are in /usr/bin.

That's why you write:
echo ${^path}/*.sh(N)

(N) disables the "no match" errors.

(you may prefere type -m '*.sh', though, here).

--
Stephane



 Sat, 14 Apr 2007 14:56:07 GMT   
 Question on order of filename expansion of {a,b}/{c,d} in bash (or csh)
In article <slrncnrt87.o8.stephane.chaze...@spam.is.invalid>,
Stephane CHAZELAS  <this.addr...@is.invalid> wrote:

Yes, you are right of course.  I realized after I had posted that I had
mistakenly referred to it as filename expansion.

For the remainder of this thread, forget the concept of filename expansion
entirely (focus only on brace expansion).

So the question remains: Is it guaranteed that: /foo/bar/{a,b}/{c,d}
will expand to:

     /foo/bar/a/c
     /foo/bar/a/d
     /foo/bar/b/c
     /foo/bar/b/d

and not:

     /foo/bar/a/c
     /foo/bar/b/c
     /foo/bar/a/d
     /foo/bar/b/d
?

(In those shells that support brace expansion.  Note that this is all
non-POSIX, so the POSIX-heads can ignore this thread)



 Sat, 14 Apr 2007 22:11:43 GMT   
 Question on order of filename expansion of {a,b}/{c,d} in bash (or csh)
2004-10-26, 14:11(+00), Kenny McCormack:
[...]
[...]

As long as it is not specified, shell developers are free to
implement it as they want. But only a twisted mind would
implement another way than bash, ksh and zsh did.

Note that bash and zsh have the {x..y} extension (not
implemented the same way). And I'd bet brace expansion
implementations behave differently WRT quoting (I seem to recall
the behavior changed in bash 3.0)

Note that at least on zsh, brace expansion conflicts a bit with
the { as in the grouping operator:

$ echo {echo,bar}
echo bar
$ {echo,bar}
zsh: command not found: echo,bar

(the closing "}" doesn't have to be preceded by a NL or ; in
zsh).

--
Stephane



 Sat, 14 Apr 2007 22:47:30 GMT   
 Question on order of filename expansion of {a,b}/{c,d} in bash (or csh)
In article <slrncnsos2.1s0.stephane.chaze...@spam.is.invalid>,
Stephane CHAZELAS  <this.addr...@is.invalid> wrote:

OK - point taken.

And don't forget csh - the shell that pioneered brace expansion.



 Sat, 14 Apr 2007 23:55:40 GMT   
 
   [ 6 post ] 

Similar Threads

1. Interactive filename expansion in BASH

2. wildcard expansion and symbolic links (csh, sh, ksh, bash)

3. Execution order of files for csh/ksh/sh/bash

4. HELP:bash: making tilde expansion after command expansion...

5. Question re: filename expansion and sh

6. filename expansion question

7. Trivia question: CSH word expansion

8. simple bash alias expansion question

9. Question about order of evaluation in ksh/bash


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software