Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: Using variables in command substitution



Thanks -- this fixed my problem. You have to escape the "|" character, e.g.:

HNAME=(uname -n \| cut -d. -f1)
. . . 

Thank you again for prompt reply! 

-----Original Message-----
From: Peter Stephenson [mailto:Peter.Stephenson@xxxxxxx] 
Sent: Monday, June 14, 2010 4:03 AM
To: Dan Luther
Cc: zsh-users@xxxxxxx
Subject: Re: Using variables in command substitution

On Mon, 14 Jun 2010 01:18:13 -0500
"Dan Luther" <dan@xxxxxxxxxxxxxx> wrote:
> 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:

You're hitting the fact that zsh doesn't split scalar variables
automatically.  See http://zsh.sourceforge.net/FAQ/zshfaq03.html#l18 .

A quick fix for the commands is to use arrays:

ME=(/usr/xpg4/bin/id -un)

etc.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ,
UK


Member of the CSR plc group of companies. CSR plc registered in England and
Wales, registered number 4187346, registered office Churchill House,
Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.829 / Virus Database: 271.1.1/2934 - Release Date: 06/13/10
14:45:00



Messages sorted by: Reverse Date, Date, Thread, Author