idallen (08/02/82)
Greg Guthrie proposed a fix to CSH to allow escapes inside
quoted strings, making CSH similar to SH in this respect.
His changes didn't handle quotes at the end of lines, e.g.
% echo "\
this doesn't print\"
a double quote"
this doesn't print
a double quote
%
The changes also didn't include escapes for "$" or "`".
I have made the following change to /usr/src/cmd/csh/sh.lex.c
to permit this escaping. The change is in routine word()
near line 180 in the file:
---------------------------------------------------------------
if (c == '\\') {
/* A fix to csh allowing escapes in quoted strings.
* This makes csh behavior the same as "sh" for items like:
* echo "#define name \"string\" "
* echo "\$SHELL"
* echo "The grave '\`' is printed."
*/
switch( c = getC(0) ){
case '"':
case '\'':
case '`':
case '$':
quoteit:
c |= QUOTE;
break;
case '\n':
/* Keep backslash in front of newline for later */
ungetC( c|QUOTE ), c = '\\';
break;
default:
if( c == HIST ){
goto quoteit;
}
/* Not a quotable character -- echo it */
ungetC(c), c = '\\';
}
}
---------------------------------------------------------------