Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Nov 2013 23:00:40 +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: r257929 - in head: bin/sh tools/regression/bin/sh/builtins
Message-ID:  <201311102300.rAAN0eAH078941@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Nov 10 23:00:39 2013
New Revision: 257929
URL: http://svnweb.freebsd.org/changeset/base/257929

Log:
  sh: Properly quote alias output from command -v.
  
  An alias should be printed by command -v as a command line; therefore, make
  the alias definition suitable for re-input to the shell.

Added:
  head/tools/regression/bin/sh/builtins/command12.0   (contents, props changed)
Modified:
  head/bin/sh/exec.c

Modified: head/bin/sh/exec.c
==============================================================================
--- head/bin/sh/exec.c	Sun Nov 10 22:42:56 2013	(r257928)
+++ head/bin/sh/exec.c	Sun Nov 10 23:00:39 2013	(r257929)
@@ -672,9 +672,11 @@ typecmd_impl(int argc, char **argv, int 
 
 		/* Then look at the aliases */
 		if ((ap = lookupalias(argv[i], 1)) != NULL) {
-			if (cmd == TYPECMD_SMALLV)
-				out1fmt("alias %s='%s'\n", argv[i], ap->val);
-			else
+			if (cmd == TYPECMD_SMALLV) {
+				out1fmt("alias %s=", argv[i]);
+				out1qstr(ap->val);
+				outcslow('\n', out1);
+			} else
 				out1fmt("%s is an alias for %s\n", argv[i],
 				    ap->val);
 			continue;

Added: head/tools/regression/bin/sh/builtins/command12.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/command12.0	Sun Nov 10 23:00:39 2013	(r257929)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+alias aa=echo\ \'\"\'
+cmd=$(command -v aa)
+alias aa=echo\ bad
+eval "$cmd"
+[ "$(eval aa)" = \" ]



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