cmorgan@mentor.com (Clark Morgan @ APD x4813) (06/06/90)
Within Bourne shell it is possible to nest command subsitution, like so: % /bin/sh $ echo `echo \`echo stuff\`` stuff This has idiom has its uses. I can't come up with similar Csh syntax that works. Here's what Csh says when handed the same command line as above: % echo `echo \`echo stuff\`` Unmatched `. Is there any way to do this in Csh? If it matters, I'm running SR10.3 on an Apollo DN4500, using either the SYSV or BSD version of Csh. If this is a frequently asked/trivial question, please don't post the answer, just send me e-mail. Thanks in advance! -- Clark O. Morgan -- Mentor Graphics Corp. cmorgan@pdx.mentor.com ...!uunet!mntgfx!cmorgan
jik@athena.mit.edu (Jonathan I. Kamens) (06/07/90)
In article <1990Jun6.082816.13649@mentor.com>, cmorgan@mentor.com (Clark Morgan @ APD x4813) writes: |> [Is it possible to do nested command substitution in csh?] No, I'm fairly certain it's not possible to do this. The traditional way to get around it is to assign the result of the inner `` to a shell variable, and then use that shell variable in the second ``, e.g.: set foo = `echo stuff` echo `$foo` |> If this is a frequently asked/trivial question, please don't |> post the answer, just send me e-mail. I haven't seen it asked in a while, and it isn't in the FAQ posting, but I have seen it asked before in this group, so perhaps it *should* be in the FAQ posting :-). Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710
limes@ouroborous.Sun.COM (Greg Limes) (06/07/90)
In article <1990Jun6.215148.9668@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes: >In article <1990Jun6.082816.13649@mentor.com>, cmorgan@mentor.com (Clark >Morgan @ APD x4813) writes: >|> [Is it possible to do nested command substitution in csh?] > > No, I'm fairly certain it's not possible to do this. Anyone else out there took Clint Staley's "unix hacking" class out at UC Santa Barbara? No? I guess I gotta pipe up then ... Without thinking too much about the problem, he tossed this one at us as an assignment. It turns out to be possible, but extremely hairy -- I tend to remember weird stuff like this, but this was *too* weird. -- Greg Limes limes@sun.com ...!sun!limes 73327,2473 CGDB02A [choose one] A Fool and his Money are soon Partying ...