From 71828da5ffc38f661b814ac36af9129833b64ae2 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 25 Aug 2013 11:42:53 +0000 Subject: [PATCH] sh: Recognize "--" as end of options in alias builtin. Aliases starting with "-" (which are non-POSIX) will need to be preceded by an alias not starting with "-" or the newly added "--". --- bin/sh/alias.c | 8 +++++--- tools/regression/bin/sh/builtins/alias4.0 | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 tools/regression/bin/sh/builtins/alias4.0 diff --git a/bin/sh/alias.c b/bin/sh/alias.c index da995bbd4733..044c869ed940 100644 --- a/bin/sh/alias.c +++ b/bin/sh/alias.c @@ -237,17 +237,19 @@ printaliases(void) } int -aliascmd(int argc, char **argv) +aliascmd(int argc __unused, char **argv __unused) { char *n, *v; int ret = 0; struct alias *ap; - if (argc == 1) { + nextopt(""); + + if (*argptr == NULL) { printaliases(); return (0); } - while ((n = *++argv) != NULL) { + while ((n = *argptr++) != NULL) { if ((v = strchr(n+1, '=')) == NULL) /* n+1: funny ksh stuff */ if ((ap = lookupalias(n, 0)) == NULL) { warning("%s: not found", n); diff --git a/tools/regression/bin/sh/builtins/alias4.0 b/tools/regression/bin/sh/builtins/alias4.0 new file mode 100644 index 000000000000..3d5efeccf2c7 --- /dev/null +++ b/tools/regression/bin/sh/builtins/alias4.0 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +unalias -a +alias --