Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Glob specifiers for intermediate path components



On Thu, Nov 27, 2014 at 2:52 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:

> A third would be something like this:
>
>     glueglob() {
>       emulate -R zsh -o csh_null_glob
>       local here there
>       while (( ARGC ))
>       do
>         here=( $^here$~1 )
>         here=( ${^here}${2:+/} )
>         shift
>       done
>       print $here
>     }
>     print -l $( noglob glueglob a(...) b(...) c(...) d(...) e(...) f(...) )

Works like a charm, thank you!

> There's almost certainly a fancy expression that could be written to
> split a(...)/b(...)/c(...)/d(...)/e(...)/f(...) on the slashes without
> being confused by the (/) glob qualifier, but I'm not going to attempt
> to write it tonight.

In Perl, it could look like:

$ perl -e '$_="a(.)/b(@)/c(/N)/d(*)/e(@)/f/g/h/i(/)"; while
(m{((.*?)(\(.*?\))?)(/|$)}g) { print "CHF 0.96\n" }'
a(.)
b(@)
c(/N)
d(*)
e(@)
f
g
h
i(/)

Not sure whether this solution is waterproof though.

Joerg



Messages sorted by: Reverse Date, Date, Thread, Author