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.
This commit is contained in:
parent
48f22b9682
commit
5d4d10e3e5
@ -672,9 +672,11 @@ typecmd_impl(int argc, char **argv, int cmd, const char *path)
|
||||
|
||||
/* 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;
|
||||
|
7
tools/regression/bin/sh/builtins/command12.0
Normal file
7
tools/regression/bin/sh/builtins/command12.0
Normal file
@ -0,0 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
alias aa=echo\ \'\"\'
|
||||
cmd=$(command -v aa)
|
||||
alias aa=echo\ bad
|
||||
eval "$cmd"
|
||||
[ "$(eval aa)" = \" ]
|
Loading…
Reference in New Issue
Block a user