summaryrefslogtreecommitdiffstats
path: root/bin/sh/eval.c
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-10-28 18:37:09 +0000
committerstefanf <stefanf@FreeBSD.org>2005-10-28 18:37:09 +0000
commit21aa82a5ae17d4a50a4fa35697043c3434de308a (patch)
tree0e857bf6739f08f4e56d9fa1aee34ddce7a13452 /bin/sh/eval.c
parent85be5dff385854a1208209ce69c374ab63970002 (diff)
downloadFreeBSD-src-21aa82a5ae17d4a50a4fa35697043c3434de308a.zip
FreeBSD-src-21aa82a5ae17d4a50a4fa35697043c3434de308a.tar.gz
Add the POSIX options -v and -V to the 'command' builtin. Both describe the
type of their argument, if it is a shell function, an alias, a builtin, etc. -V is more verbose than -v. PR: 77259, 84539
Diffstat (limited to 'bin/sh/eval.c')
-rw-r--r--bin/sh/eval.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index ddf2275..fecc4de 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -976,6 +976,7 @@ commandcmd(int argc, char **argv)
struct strlist *sp;
char *path;
int ch;
+ int cmd = -1;
for (sp = cmdenviron; sp ; sp = sp->next)
setvareq(sp->text, VEXPORT|VSTACK);
@@ -983,11 +984,17 @@ commandcmd(int argc, char **argv)
optind = optreset = 1;
opterr = 0;
- while ((ch = getopt(argc, argv, "p")) != -1) {
+ while ((ch = getopt(argc, argv, "pvV")) != -1) {
switch (ch) {
case 'p':
path = stdpath;
break;
+ case 'v':
+ cmd = TYPECMD_SMALLV;
+ break;
+ case 'V':
+ cmd = TYPECMD_BIGV;
+ break;
case '?':
default:
error("unknown option: -%c", optopt);
@@ -996,6 +1003,11 @@ commandcmd(int argc, char **argv)
argc -= optind;
argv += optind;
+ if (cmd != -1) {
+ if (argc != 1)
+ error("wrong number of arguments");
+ return typecmd_impl(2, argv - 1, cmd);
+ }
if (argc != 0) {
old = handler;
handler = &loc;
OpenPOWER on IntegriCloud