From: "Dan Luther" <dan@theluthers.net>
To: <zsh-users@zsh.org>
Subject: Using variables in command substitution
Date: Mon, 14 Jun 2010 01:18:13 -0500 [thread overview]
Message-ID: <001201cb0b89$63e2e3b0$2ba8ab10$@net> (raw)
[-- Attachment #1: Type: text/plain, Size: 779 bytes --]
Hello,
I'm hoping someone can explain this.
I'm trying to unify my .zshrc across a couple of platforms, and I ran across
an interesting ZSH behavior. Essentially, I want to assign a variable to the
name of a specific command for later substitution:
if [$(uname)="SunOS"]; then
ME="/usr/xpg4/bin/id -un"
elif [$(uname)="Linux"]; then
ME="id -un"
else
ME="who am i | cut -d ' ' -f1"
fi
HNAME=$(uname -n | cut -d. -f1)
. . .
cd() { chdir "$@"; prompt="[$($ME)@$HNAME] $(pwd)> "; }
. . .
When I try to use the "cd" redefinition, I get:
.zshrc: no such file or directory /usr/xpg4/bin/id -un
Is it possible to use variables in command expansion at all, or am I just
doing it wrong?
Thank you for your time.
next reply other threads:[~2010-06-14 6:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-14 6:18 Dan Luther [this message]
2010-06-14 9:02 ` Peter Stephenson
2010-06-14 14:58 ` Dan Luther
2010-06-14 13:36 ` Benjamin R. Haskell
2010-06-14 16:57 ` Dan Luther
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='001201cb0b89$63e2e3b0$2ba8ab10$@net' \
--to=dan@theluthers.net \
--cc=zsh-users@zsh.org \
/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).