Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Variable with Variable Name
- X-seq: zsh-users 11834
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: zzapper <david@xxxxxxxxxx>
- Subject: Re: Variable with Variable Name
- Date: Thu, 13 Sep 2007 18:30:58 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <Xns99A995AD16037zzappergmailcom@xxxxxxxxxxx>
- Mail-followup-to: zzapper <david@xxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns99A995AD16037zzappergmailcom@xxxxxxxxxxx>
On Wed, Sep 12, 2007 at 01:43:46PM +0000, zzapper wrote:
> Hi,
>
> function SSS()
> {
> # description : create a set variable with variable name
> $1=`pwd`; # What I want but THIS DOESNT WORK
> echo $1
> }
>
> So if I called this
>
> > SSS fred
>
> Would create a variable fred containing the path of the current directory
[...]
SSS() {
eval "$1=\$PWD"
eval "printf '%s\n' \"$1=\$$1\""
}
Which happens to even be POSIX code.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author