Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to create unnamed temporary arrays?
- X-seq: zsh-users 3644
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: How to create unnamed temporary arrays?
- Date: Mon, 26 Feb 2001 06:38:59 +0000
- In-reply-to: <87elwvvw2f.fsf@xxxxxxxxxxxxxxxx>
- In-reply-to: <200102190955.KAA10015@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- In-reply-to: <87snl9teqa.fsf@xxxxxxxxxxxxxxxx>
- In-reply-to: <Pine.SV4.4.20.0102202132470.24316-100000@xxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <87elwvvw2f.fsf@xxxxxxxxxxxxxxxx> <200102190955.KAA10015@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <87snl9teqa.fsf@xxxxxxxxxxxxxxxx> <Pine.SV4.4.20.0102202132470.24316-100000@xxxxxxxxxxxxxxxxxxxxx>
On Feb 19, 11:52am, Hannu Koivisto wrote:
} Subject: How to create unnamed temporary arrays?
}
} I'm currently using something like this to list the base names of
} files in /usr/local/etc/packages/ directory, each name on its own
} line:
}
} echo ${(F)$(echo /usr/local/etc/packages/*(.:t:r))}
}
} This has the obvious problem that it doesn't work if filenames have
} spaces in them.
There was a discussion of exactly this subject on zsh-users in December.
Start with
http://www.zsh.org/mla/users/2000/msg00728.html
(The canonical way to access that should be
http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=3560
but the redirector doesn't seem to be working right now.)
On Feb 20, 9:38pm, Andrej Borsenkow wrote:
} Subject: Re: How to create unnamed temporary arrays?
}
} The idea I had today (in relation to other things) was to introduce new
} syntax, something like
}
} ${foo-(bar baz)}
}
} (note braces).
You mean the parens?
The problem with that is that it's semantically incompatible with syntax
that is parseable by standard sh, in which the parens would not have any
special meaning in that expression. (Zsh's other overloadings of parens
have been to introduce them where they'd actually cause a syntax error
in sh.) The above would have to be combined with some other signifier,
such as a new parameter flag, or an option.
The real issue of course is that there's no way to do filename generation
within a parameter expansion without resorting to command substitution.
Even given a syntax for embedding an array construction within the ${...},
you can't accomplish what's being asked for in 3560 and 3630 unless you
can also force a glob.
So the best mechanism for creating an "anonymous array" is probably:
"${(ps:\0:)$(print -nN ...)}"
where `...' is the glob expression or whatever, which of course can be
optimized depending on what you plan to do with the array.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author