[net.unix] question about csh quoting

sloane@noscvax.UUCP (05/07/84)

"The UNIX Programming Environment" by Kernighan and Pike (copyright 1984
by Bell Labs) states the following:

	"...Quotes of one kind protect quotes of the other kind:

		$ echo "Don't do that!"
		Don't do that!
		$
	..."

When I tried that (4.2bsd with csh) it did the following:

		%echo "Don't do that!"
		": Event not found.
		%

Is this something different in the c-shell, or is this an error in
the c-shell?


      Gary K. Sloane
      c/o Naval Ocean Systems Center
      COTD Building 1 Room B205
      San Diego, California 92152

      MILNET: sloane@nosc
      UUCP:   ...{sdcsvax}!noscvax!sloane
      DDD: (619) 225-8401 x391

merlyn@sequent.UUCP (05/08/84)

> From: sloane@noscvax.UUCP
> Message-ID: <433@noscvax.UUCP>
> Date: Mon, 7-May-84 07:52:51 PDT
> 
> "The UNIX Programming Environment" by Kernighan and Pike (copyright 1984
> by Bell Labs) states the following:
> 	"...Quotes of one kind protect quotes of the other kind:
> 		$ echo "Don't do that!"
> 		Don't do that!
> 		$
> 	..."
> When I tried that (4.2bsd with csh) it did the following:
> 		%echo "Don't do that!"
> 		": Event not found.
> 		%
> Is this something different in the c-shell, or is this an error in
> the c-shell?

Different in the C-shell.  You have an exclamation mark in your command line,
and that takes higher precedence than even single quotes (sometimes icky!).

To get C-shell to echo "Don't do that!", you need to say:
		% echo "Don't do that\!"
and all will be fine.

-- A particularly personal and original observation from the thought-stream of
Randal L. ("C shell seller by C shore") Schwartz, esq. (merlyn@sequent.UUCP)
	(Official Legendary Sorcerer of the 1984 Summer Olympics)
Sequent Computer Systems, Inc. (503)626-5700 (sequent = 1/quosine)
UUCP: {decwrl,ogcvax,pur-ee,rocks34,shell,unisoft,vax135,verdix}!sequent!merlyn

keesan@bbncca.ARPA (Morris Keesan) (05/08/84)

------------------------------
>>>From: sloane@noscvax.UUCP
>>>    .
>>>    .
>>>When I tried that (4.2bsd with csh) it did the following:
>>>
>>>		   %echo "Don't do that!"
>>>		   ": Event not found.
>>>		   %
>>>
>>>Is this something different in the c-shell, or is this an error in
>>>the c-shell?

    This is something different in csh.  An exclamation point (!) introduces
a history event.  In this case, you were referring to history event "", which
was not found.  One type of quotes does indeed protect the other kind, even
in csh, but "" doesn't protect !.
-- 
					Morris M. Keesan
					{decvax,linus,wjh12,ima}!bbncca!keesan
					keesan @ BBN-UNIX.ARPA

gwyn@brl-vgr.ARPA (Doug Gwyn ) (05/09/84)

Kernighan & Pike are describing the "standard" (Bourne) shell, not
the Cshell.  Other things they describe will also not work under
the Cshell.  You seem to have stumbled on the fact that !anything
usually triggers one of the "history" features of the Cshell (which
also has "echo" built-in, by the way).

nather@utastro.UUCP (Ed Nather) (05/09/84)

[]
	"The UNIX Programming Environment" by Kernighan and Pike (copyright 1984
	by Bell Labs) states the following:

		"...Quotes of one kind protect quotes of the other kind:

			$ echo "Don't do that!"
			Don't do that!
			$
		..."

	When I tried that (4.2bsd with csh) it did the following:

			%echo "Don't do that!"
			": Event not found.
			%

	Is this something different in the c-shell, or is this an error in
	the c-shell?

You have banged into job control -- the "!" character signifies some previous
"event" to the C-Shell, despite the quote.  You'll find the same problem if
you try to send mail separating site names :  mail seismo!alice will get the
response "alice: Event not found."  The solution is to "escape" the "!" 
character with a backslash:  "Don't do that\!" will work fine.  So far as I
know, *only* the "!" character causes this kind of trouble with the C-Shell.
But it *is* a pain in the \*ss.


      Gary K. Sloane
      c/o Naval Ocean Systems Center
      COTD Building 1 Room B205
      San Diego, California 92152

      MILNET: sloane@nosc
      UUCP:   ...{sdcsvax}!noscvax!sloane
      DDD: (619) 225-8401 x391


-- 

                                       Ed Nather
                                       ihnp4!{ut-sally,kpno}!utastro!nather
                                       Astronomy Dept., U. of Texas, Austin

mark@elsie.UUCP (05/09/84)

<>
The problem with:

		%echo "Don't do that!"
		": Event not found.
		%

is not the "'", but the "!", which evokes the history mechanism of csh.

	%echo "Don't do that"
and
	%echo "Don't do that\!"

work just fine. Having to, occasionaly, backslash-protect the "!" is a small
price to pay for having history. Evoking the mechanism inside quotes is
probably a bug in csh, but easily overcome. Question is: is it worth some poor
hacker's time to fix it?
					--elsie!mark

-- 
Mark J. Miller
NIH/NCI/DCE/LEC
UUCP:	decvax!harpo!seismo!rlgvax!cvl!elsie!mark
Phone:	(301) 496-5688

mcnabb@uiuccsb.UUCP (05/10/84)

#R:noscvax:-43300:uiuccsb:19300016:000:869
uiuccsb!mcnabb    May 10 09:16:00 1984


     > When I tried that (4.2bsd with csh) it did the following:
     > 		%echo "Don't do that!"
     > 		": Event not found.
     > Is this something different in the c-shell, or is this an
     > error in the c-shell?

You told the csh to echo the string "Don't do that" followed by the
string returned by the history substitution !", but since you had not
previously run any commands beginning with the character " the csh
could not make the !" substitution.  It could not find the (history)
event beginning with ".  If it had, you would then have gotten a message
Unmatched " since you need another " at the end.
Correct way:
				% echo "Don't do that\!"
Just for grins, try running:
				% "echo" hi
				% echo "Don't do that!"
				% echo "Don't do that!""

        D. McNabb
        USENET:	...!{pur-ee,ihnp4}!uiucdcs!mcnabb
        CSNET:	mcnabb.uiuc@rand-relay

jrb@wdl1.UUCP (jrb ) (05/11/84)

#R:noscvax:-43300:wdl1:1300001:000:492
wdl1!jrb    May  9 10:48:00 1984

The message was caused by the exclamation point in the argument to 'echo'
The 'csh' history mechanism was trying to expand it into a previous
command and failed.  It should be possible to escape the exclamation point
by preceding it with a backslash ('\').

				John R Blaker
				Ford Aerospace & Communications Corporation
				Western Development Laboratories Division
				3939 Fabian Way
				Palo Alto, CA  94303
				UUCP:	...!fortune!wdl1!jrb
				ARPA:	jrb@FORD-WDL1
					blaker@FORD-WDL2

woods@hao.UUCP (Greg Woods) (05/11/84)

  If the character following "!" is a space character (blank, tab or newline),
then history is not invoked. I use this fact all the time in my shell
scripts.

% echo "Don't do that! "

works just fine, and is a hell of a lot easier to type (*and* read!) than
backslashes.

			   GREG
-- 
{ucbvax!hplabs | allegra!nbires | decvax!stcvax | harpo!seismo | ihnp4!stcvax}
       		        !hao!woods

seifert@ihuxl.UUCP (D.A. Seifert) (05/11/84)

why does csh use '!' ? Is a printing character necessary?
(does anyone still use '#' and '@' for erase and kill?)
Why not use a non-printing character for calling up the last command?

for example, ksh uses ^p (control-p) to retrieve the previous
command.  You can then execute it again by hitting return, or
edit it using emacs or vi commands.  The only problem I've
seen with this is that all the decwriter consoles have big
signs on them saying don't use ^p. Appariently it locks up a
decwriter.

{apologies to those of you who don't want to hear about ksh}
-- 
	_____
       /_____\	   	    That auto-crossing beagle,
      /_______\			      Snoopy
	|___|		    BMWCCA, Windy City Chapter
    ____|___|_____	       ihnp4!ihuxl!seifert

seifert@ihuxl.UUCP (D.A. Seifert) (05/11/84)

References: <433@noscvax.UUCP> <904@elsie.UUCP>

why does csh use '!' ? Is a printing character necessary?
(does anyone still use '#' and '@' for erase and kill?)
Why not use a non-printing character for calling up the last command?

for example, ksh uses ^p (control-p) to retrieve the previous
command.  You can then execute it again by hitting return, or
edit it using emacs or vi commands.  The only problem I've
seen with this is that all the decwriter consoles have big
signs on them saying don't use ^p. Appariently it locks up a
decwriter.

Disclaimers:

a) I've never used csh, so maybe I'm missing something here.
b) apologies to those of you who don't want to hear about ksh
-- 
	_____
       /_____\	   	    That auto-crossing beagle,
      /_______\			      Snoopy
	|___|		    BMWCCA, Windy City Chapter
    ____|___|_____	       ihnp4!ihuxl!seifert

guy@rlgvax.UUCP (05/13/84)

> why does csh use '!' ? Is a printing character necessary?
> (does anyone still use '#' and '@' for erase and kill?)
> Why not use a non-printing character for calling up the last command?

> for example, ksh uses ^p (control-p) to retrieve the previous
> command.  You can then execute it again by hitting return, or
> edit it using emacs or vi commands.  The only problem I've
> seen with this is that all the decwriter consoles have big
> signs on them saying don't use ^p. Appariently it locks up a
> decwriter.

The C shell history mechanism does more than just retrieve the previous
command; it also permits you to extract little bits of several previous
commands and glue them back together again.  (Question: how many people
actually extract little bits of several previous commands and glue them
back together to make a new command, as opposed to retrieving a previous
command in its entirety and editing it?)  Given non-Berkeley UNIXes habit
of echoing control characters as themselves, it could be awkward to use
a non-printing character as your history character - the C shell does let
you set your history character, so if you don't like "!" you can choose
another one.

^P doesn't lock up a DECwriter, but it locks up a VAX-11 or some PDP-11
consoles.  The console is really talking to some sort of micro (LSI-11
in the case of a VAX-11/780) which interprets ^P as a control character
saying "don't act as a console to the main computer, act as a console to
the micro".

As for still using "#" and "@" as erase and kill characters, the real question
should be "why were printing characters used as erase and kill characters
in the first place?"  On Multics you sort of had to use them - you had
terminals which didn't *have* any control characters, like IBM 2741's, and
the interface to the host was half-duplex, so you couldn't do anything
clever with the erase and kill character - but UNIX ran on DEC machines
using ASCII terminals and full-duplex interfaces, which DEC used quite well
to give a reasonable user interface to the terminal driver.  Several
people (Berkeley, Harvard, etc.) have put a DEC-style terminal driver into
UNIX.  Why didn't Bell?  (And why did it take until V7 for Bell to support
XON/XOFF, and until *System III* for Bell to pick up the idea of "CRT rubout"?)

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

merlyn@sequent.UUCP (05/14/84)

> From: seifert@ihuxl.UUCP
> Message-ID: <1100@ihuxl.UUCP>
> Date: Fri, 11-May-84 05:41:31 PDT
> 
> ...The only problem I've
> seen with this is that all the decwriter consoles have big
> signs on them saying don't use ^p. Appariently it locks up a
> decwriter....

It isn't the decwriter that gets locked up.  The VAX cpu senses ^P 
on the console (when not in Secure mode) as the "front-panel" trigger...
your decwriter becomes the VAX's front panel.  For example, ^P
followed by H halts the cpu, and ^P followed by B reboots it.
^P followed by other incantations dumps out registers, memory, and
so on.

Not a nice thing to do while UNIX is up and running!

If you leave the front panel keyswitch in "secure", that won't happen
though.  It's nothing to do with the fact that you have a decwriter for
a console.

-- A particularly personal and original observation from the thought-stream of
Randal L. ("control-P'ed") Schwartz, esq. (merlyn@sequent.UUCP)
	(Official Legendary Sorcerer of the 1984 Summer Olympics)
Sequent Computer Systems, Inc. (503)626-5700 (sequent = 1/quosine)
UUCP: {decwrl,ogcvax,pur-ee,rocks34,shell,unisoft,vax135,verdix}!sequent!merlyn

P.S. UNIX is a trademark of somebody.  VAX is a tradmark of Dec.  Decwriter
probably is too, now that I think about it.

dyer@vaxuum.DEC (Example #22) (05/16/84)

Re: question about csh quoting_________________________________________________

> ...all the decwriter consoles have big signs on them saying don't use ^p.
> Apparently it locks up a decwriter.

	Every VAX has a key-operated switch on it that can be used to turn
the console on and off.  It looks to me as if your system manager leaves the
console on and then expects everyone to avoid typing ^P.  This isn't very
clever.  Anyone (including whoever comes in at night to mop the floor) can
type ^P and they'll get a ">>>" prompt.  Guess what happens if they type
"HALT?"
	Your system manager should disable the console and use the key to
enable it.  Much safer.
	(-: You didn't *really* think a fine product from DEC would lock
up from user input, did you? :-)
		<_Jym_>
    __/ Jym Dyer <> Digital Equipment Corporation <> Nashua, NH \__
 __/ Arpanet:  dyer%vaxuum.DEC@DECWRL.ARPA <> E-Net:  VAXUUM::DYER \__
/ Usenet:  ...{allegra|decvax|ucbvax}!decwrl!dec-rhea!dec-vaxuum!dyer \

jab@uokvax.UUCP (05/16/84)

#R:noscvax:-43300:uokvax:6100032:000:1006
uokvax!jab    May 15 20:27:00 1984

/***** uokvax:net.unix / noscvax!sloane /  7:03 pm  May  8, 1984 */
"The UNIX Programming Environment" by Kernighan and Pike (copyright 1984
by Bell Labs) states the following:

	"...Quotes of one kind protect quotes of the other kind:

		$ echo "Don't do that!"
		Don't do that!
		$
	..."

When I tried that (4.2bsd with csh) it did the following:

		%echo "Don't do that!"
		": Event not found.
		%

Is this something different in the c-shell, or is this an error in
the c-shell?
/* ---------- */

Very different about the cshell. That "!" is quite a special character,
being your "history character". When the cshell parser saw that
	!"
it tried to remember what command you had previously typed in that began
with a double quote. When it didn't find it, it complained.

To prevent the exclamation point from being special, we can make some
other characters serve the functions of "!" and "^":
	% set histchars = "%*"
Then what Kernighan/Pike suggest works for the cshell also.

	Jeff Bowles
	Lisle, IL

jso@edison.UUCP (05/18/84)

Re: ^P on VAX console:
On the 11/44 you could leave console mode by typing `c' for continue.
On the 780 I believe you can type
SET MODE PRO

-John