From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: zzapper <david@tvis.co.uk>
Cc: zsh-users@sunsite.dk
Subject: Re: Variable with Variable Name
Date: Thu, 13 Sep 2007 18:30:58 +0100 [thread overview]
Message-ID: <20070913173058.GC5335@sc.homeunix.net> (raw)
In-Reply-To: <Xns99A995AD16037zzappergmailcom@80.91.229.5>
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
next parent reply other threads:[~2007-09-13 17:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Xns99A995AD16037zzappergmailcom@80.91.229.5>
2007-09-13 17:30 ` Stephane Chazelas [this message]
2007-09-13 18:17 ` zzapper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070913173058.GC5335@sc.homeunix.net \
--to=stephane_chazelas@yahoo.fr \
--cc=david@tvis.co.uk \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).