From root@newsguy.com  Fri Jan  8 12:05:28 1999
Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA17465
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 8 Jan 1999 12:05:28 -0800 (PST)
          (envelope-from root@newsguy.com)
Received: from local.ocn.ne.jp by peach.ocn.ne.jp (8.9.1a/OCN) id FAA28234; Sat, 9 Jan 1999 05:04:57 +0900 (JST)
Received: (from root@localhost)
	by local.ocn.ne.jp (8.9.1/8.8.6) id EAA00618;
	Sat, 9 Jan 1999 04:56:41 +0900 (JST)
Message-Id: <199901081956.EAA00618@local.ocn.ne.jp>
Date: Sat, 9 Jan 1999 04:56:41 +0900 (JST)
From: dcs@newsguy.com
Reply-To: dcs@newsguy.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Loader's parser can't escape characters
X-Send-Pr-Version: 3.2

>Number:         9397
>Category:       kern
>Synopsis:       Loader's parser can't escape characters
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan  8 12:10:01 PST 1999
>Closed-Date:    Sat Jan 9 21:11:15 PST 1999
>Last-Modified:  Sat Jan  9 21:12:10 PST 1999
>Originator:     Daniel C. Sobral
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:

	Three stage boot loader.

>Description:

	There is no way to escape a character in loader. As a result,
it becomes impossible, for instance, to set the variable PROMPT to it's
default.

>How-To-Repeat:

	UTSL?
	Enter "set prompt=${currdev}" and then "show", in the loader,
just for fun...

>Fix:

	Apply the following two patches. Notice that the parser presently
eats away backslashes. It preserves them in case of quotes, though it then
do nothing with it. The following patches preserve the backslash when it
precedes $ too, and *do* something about it. :-) Escaping other characters
can still be done using \\.


--- sys/boot/common/interp_parse.c	Mon Jan  4 15:39:21 1999
+++ sys/boot/common/interp_parse.c.orig	Mon Jan  4 15:10:28 1999
@@ -100,11 +100,7 @@
     while (*p) {
 	switch (state) {
 	case STR:
-	    if ((*p == '\\') && p[1] ) {
-		p++;
-		PARSE_FAIL(i == (PARSE_BUFSIZE - 1));
-		buf[i++] = *p++;
-	    } else if (isquote(*p)) {
+	    if (isquote(*p)) {
 		quote = quote ? 0 : *p;
 		++p;
 	    }


--- sys/boot/common/interp_backslash.c.orig	Wed Jan  6 05:59:26 1999
+++ sys/boot/common/interp_backslash.c	Wed Jan  6 05:59:36 1999
@@ -11,7 +11,7 @@
  * Jordan K. Hubbard
  * 29 August 1998
  *
- *	$Id: interp_backslash.c,v 1.1 1999/01/05 20:52:32 root Exp $
+ *	$Id: interp_backslash.c,v 1.2 1999/01/05 20:54:09 root Exp root $
  *
  * Routine for doing backslash elimination.
  */
@@ -55,6 +55,12 @@
 	    /* preserve backslashed quotes */
 	    case '\'':
 	    case '"':
+		new_str[i++] = '\\';
+		new_str[i++] = *str++;
+		break;
+
+	    /* preserve backslashed dollars */
+	    case '$':
 		new_str[i++] = '\\';
 		new_str[i++] = *str++;
 		break;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: msmith 
State-Changed-When: Sat Jan 9 21:11:15 PST 1999 
State-Changed-Why:  
Patches applied, seem to work 
>Unformatted:
