Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jun 2009 22:53:34 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r194786 - head/bin/sh
Message-ID:  <200906232253.n5NMrYpp093488@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Tue Jun 23 22:53:34 2009
New Revision: 194786
URL: http://svn.freebsd.org/changeset/base/194786

Log:
  Quote -x tracing output so it is unambiguous.
  
  It is usually but not always suitable for re-input to the shell.
  
  Approved by:	ed (mentor) (implicit)

Modified:
  head/bin/sh/eval.c

Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c	Tue Jun 23 22:47:34 2009	(r194785)
+++ head/bin/sh/eval.c	Tue Jun 23 22:53:34 2009	(r194786)
@@ -642,17 +642,32 @@ evalcommand(union node *cmd, int flags, 
 	/* Print the command if xflag is set. */
 	if (xflag) {
 		char sep = 0;
+		const char *p;
 		out2str(ps4val());
 		for (sp = varlist.list ; sp ; sp = sp->next) {
 			if (sep != 0)
 				outc(' ', &errout);
-			out2str(sp->text);
+			p = sp->text;
+			while (*p != '=' && *p != '\0')
+				out2c(*p++);
+			if (*p != '\0') {
+				out2c(*p++);
+				out2qstr(p);
+			}
 			sep = ' ';
 		}
 		for (sp = arglist.list ; sp ; sp = sp->next) {
 			if (sep != 0)
 				outc(' ', &errout);
-			out2str(sp->text);
+			/* Disambiguate command looking like assignment. */
+			if (sp == arglist.list &&
+					strchr(sp->text, '=') != NULL &&
+					strchr(sp->text, '\'') == NULL) {
+				out2c('\'');
+				out2str(sp->text);
+				out2c('\'');
+			} else
+				out2qstr(sp->text);
 			sep = ' ';
 		}
 		outc('\n', &errout);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906232253.n5NMrYpp093488>