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)" = \" ]
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to