Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: convolutions
- X-seq: zsh-users 20911
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: convolutions
- Date: Sat, 7 Nov 2015 01:32:44 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern_com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=c/TbxOtLfKuXLwQ3UllhL0lO95G3XMiaYVJvvE1qG7Q=; b=xOb+9ArhFD7dQKMIpi2GYidJWrxqucyI5z/UhS8+WZep7yiJTlN5lqMV3+FRlq/5AZ wMFEtiUaCu5cJSUEL5P+sWZC18vOGK+ODP76KW51GrRB8W6Utjc5IAZpATs6U807ApZw 38lodbrP8L1R0CjCU7HZmnLagbXfOuD4NWOtBkvEqWJl2j6NoKOCPI7/+oB/Q3zyBAP0 Uh9Fp8tG2GjQcp6wbyZNWEoC/UQDX6/l9FbZV4roxsjJWKqFlbvaqmdXXtLZKT2T98YO 1ZyhCyVZfZ16mJZOrrQRde3pFNFDQ51dsvrdq6fw36lrvIuvsNOBaIhv58Un7QqCw1T2 xzGg==
- In-reply-to: <563D9B54.9010604@eastlink.ca>
- 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
- References: <563D5ED5.1070102@eastlink.ca> <CAH+w=7bzDJV5bLSr3=bVkAoOm-Yov3DU9w58eqr6daJFCNvw-w@mail.gmail.com> <563D9B54.9010604@eastlink.ca>
On Nov 6, 10:33pm, Ray Andrews wrote:
} Subject: Re: convolutions
}
} I did indeed edit it a bit. Here's the pasted actual test file:
}
} test2 ()
} {
} echo "$(eval echo "\${$(cat junk1)}")" >! junk2
} cat junk2
} }
}
} ... which works as advertised.
That will fail with "bad substitution" for anything more than a single
word in the file "junk1".
torch% echo "this is some text" > junk1
torch% test2 ()
{
echo "$(eval echo "\${$(cat junk1)}")" >! junk2
cat junk2
}
torch% test2
(eval):1: bad substitution
torch%
You can't just throw ${ } around any arbitrary thing and have it act
like a parameter expansion -- which is what is happening during the
eval when you have used \$ in the original expression:
torch% setopt xtrace verbose
torch% test2
test2
+Src/zsh:25> test2
+test2:2> cat junk1
+test2:2> eval echo '${this is some text}'
(eval):1: bad substitution
+test2:2> echo ''
+test2:3> cat junk2
torch%
-- and you don't even need it there in this case:
torch% test2 ()
{
echo "$(eval echo "$(cat junk1)")" >! junk2
cat junk2
}
torch% some=OTHER
torch% echo 'this is $some text' >| junk1
torch% test2
this is OTHER text
torch%
} > print -R "${(e)$(<in_file)}" >| out_file
}
} Does the trick, thanks, it's no shorter, but much more respectable.
} print has many tricks up it's sleeve.
Sigh. No, "-R" is explicitly telling "print" not to do any tricks at
all. It's the (e) parameter expansion flag that's doing the work.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author