From 65519ccb4da5884ac3a40c98cd73576203d0537e Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 30 Aug 2013 12:09:59 +0000 Subject: [PATCH] sh: Recognize "--" as end of options in type builtin. This implementation makes minimal changes: command names starting with "-" (other than "--") can still be queried normally. --- bin/sh/exec.c | 2 ++ tools/regression/bin/sh/builtins/type3.0 | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 tools/regression/bin/sh/builtins/type3.0 diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 5f78de91a32..9f8e029933e 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -762,5 +762,7 @@ typecmd_impl(int argc, char **argv, int cmd, const char *path) int typecmd(int argc, char **argv) { + if (argc > 2 && strcmp(argv[1], "--") == 0) + argc--, argv++; return typecmd_impl(argc, argv, TYPECMD_TYPE, bltinlookup("PATH", 1)); } diff --git a/tools/regression/bin/sh/builtins/type3.0 b/tools/regression/bin/sh/builtins/type3.0 new file mode 100644 index 00000000000..87cccdd812c --- /dev/null +++ b/tools/regression/bin/sh/builtins/type3.0 @@ -0,0 +1,3 @@ +# $FreeBSD$ + +[ "$(type type)" = "$(type -- type)" ]