Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Using variables in command substitution
- X-seq: zsh-users 15119
- From: "Dan Luther" <dan@xxxxxxxxxxxxxx>
- To: <zsh-users@xxxxxxx>
- Subject: Using variables in command substitution
- Date: Mon, 14 Jun 2010 01:18:13 -0500
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Sender: "Dan Luther" <dan@xxxxxxxxxxxxxx>
- Thread-index: AcsLiV6MqgMgfv6OR4Sfd97S4jioTg==
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author