csh quoting question: nested command substitution

Jerry Peek jdpeek at rodan.acs.syr.edu
Thu Jul 26 10:51:08 AEST 1990


Okay, I can tell that I obviously don't understand csh quoting.
I want to set the csh prompt, but this question is really more generic
than prompt-setting.

In the Bourne shell, I can do:
	PS1="`/bin/expr \`/bin/hostname\` : '\([^.]*\)'`$ "
which runs basename, then strips off anything after the local host name.
So, if /bin/hostname prints rodan.acs.syr.edu, the prompt is rodan$.
And, if /bin/hostname prints rodan, the prompt is still rodan$.

I know there are lots of other ways to do this (pipe to sed, store
hostname output in a shell variable first, etc.).
But I want to do it in csh, in a nice one-liner like sh lets me.
No matter what I do, I get some kind of syntax error.
Can someone at least tell me how... and, better, tell me *why*?  Thanks.

--Jerry Peek; Syracuse University Academic Computing Services; Syracuse, NY
  jdpeek at rodan.acs.syr.edu, JDPEEK at SUNRISE.BITNET        +1 315 443-3995



More information about the Comp.unix.questions mailing list