in reply to Re: String expansion script
in thread String expansion script

I for one would prefer not to see this idea made specific to pathname matching. I see it more as a kind of narrow-case templating. Comparing it to capabilities currently available in shells may not be fair or desirable; for example, the brace expansion features of zsh/bash result only in the names of existing paths that match; so if you say ls m{8:11} but have no files matching that pattern, the result is null, not m8 m9 m10 m11.

As for nesting - I think calling the expander reiteratively (or recursively ;-) could give you that.

Replies are listed 'Best First'.
Re^3: String expansion script
by ambrus (Abbot) on Feb 03, 2005 at 20:30 UTC

    Brace expansion is not specific to pathname matching. I've shown you: type

    echo a{1..3}
    you get
    a1 a2 a3
    even if such files do not exist.
    echo > a1; ls a{1..3}
    prints
    ls: a2: No such file or directory ls: a3: No such file or directory a1

    There is a filename matching feature too, in bash it looks like this:

    shopt -s extglob echo a@(1|2|3)
    is really similar to the friendly echo a[1-3], it prints
    a1
    if a1 exists but the other files don't. (Don't ask me how it works in zsh.) There is no numeric range variant of this though.
      Yah, I know. That occurred to me after I posted. /me hasn't had his cup of coffee yet.