svn commit: r212339 - in head: bin/sh tools/regression/bin/sh/builtins

Jilles Tjoelker jilles at FreeBSD.org
Wed Sep 8 20:35:44 UTC 2010


Author: jilles
Date: Wed Sep  8 20:35:43 2010
New Revision: 212339
URL: http://svn.freebsd.org/changeset/base/212339

Log:
  sh: Fix 'read' if all chars before the first IFS char are backslash-escaped.
  
  Backslash-escaped characters did not set the flag for a non-IFS character.
  
  MFC after:	2 weeks

Added:
  head/tools/regression/bin/sh/builtins/read4.0   (contents, props changed)
  head/tools/regression/bin/sh/builtins/read4.0.stdout   (contents, props changed)
Modified:
  head/bin/sh/miscbltin.c

Modified: head/bin/sh/miscbltin.c
==============================================================================
--- head/bin/sh/miscbltin.c	Wed Sep  8 20:10:29 2010	(r212338)
+++ head/bin/sh/miscbltin.c	Wed Sep  8 20:35:43 2010	(r212339)
@@ -174,6 +174,7 @@ readcmd(int argc __unused, char **argv _
 			continue;
 		if (backslash) {
 			backslash = 0;
+			startword = 0;
 			if (c != '\n')
 				STPUTC(c, p);
 			continue;

Added: head/tools/regression/bin/sh/builtins/read4.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/read4.0	Wed Sep  8 20:35:43 2010	(r212339)
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+printf '%s\n' '\a\ b c'	| { read a b; printf '%s\n' "x${a}x${b}x"; }
+printf '%s\n' '\a b\ c'	| { read a b; printf '%s\n' "x${a}x${b}x"; }
+printf '%s\n' '\a\:b:c'	| { IFS=: read a b; printf '%s\n' "x${a}x${b}x"; }
+printf '%s\n' '\a:b\:c'	| { IFS=: read a b; printf '%s\n' "x${a}x${b}x"; }
+printf '%s\n' '\\ a'	| { read a b; printf '%s\n' "x${a}x${b}x"; }
+printf '%s\n' '\\:a'	| { IFS=: read a b; printf '%s\n' "x${a}x${b}x"; }
+printf '%s\n' '\\\ a'	| { read a b; printf '%s\n' "x${a}x${b}x"; }
+printf '%s\n' '\\\:a'	| { IFS=: read a b; printf '%s\n' "x${a}x${b}x"; }

Added: head/tools/regression/bin/sh/builtins/read4.0.stdout
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/read4.0.stdout	Wed Sep  8 20:35:43 2010	(r212339)
@@ -0,0 +1,8 @@
+xa bxcx
+xaxb cx
+xa:bxcx
+xaxb:cx
+x\xax
+x\xax
+x\ axx
+x\:axx


More information about the svn-src-head mailing list