diff options
Diffstat (limited to 'bin/sh/expand.c')
-rw-r--r-- | bin/sh/expand.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c index 73cedc0..d6d34c4 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <limits.h> #include <stdio.h> +#include <string.h> /* * Routines to expand arguments to commands. We have to deal with @@ -1521,3 +1522,24 @@ cvtnum(int num, char *buf) STPUTC(*p++, buf); return buf; } + +/* + * Do most of the work for wordexp(3). + */ + +int +wordexpcmd(int argc, char **argv) +{ + size_t len; + int i; + + out1fmt("%08x", argc - 1); + for (i = 1, len = 0; i < argc; i++) + len += strlen(argv[i]); + out1fmt("%08x", (int)len); + for (i = 1; i < argc; i++) { + out1str(argv[i]); + out1c('\0'); + } + return (0); +} |