summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/sh/builtins.def1
-rw-r--r--bin/sh/expand.c22
-rw-r--r--bin/sh/expand.h1
3 files changed, 24 insertions, 0 deletions
diff --git a/bin/sh/builtins.def b/bin/sh/builtins.def
index 233e25f..a5d4542 100644
--- a/bin/sh/builtins.def
+++ b/bin/sh/builtins.def
@@ -93,3 +93,4 @@ aliascmd alias
ulimitcmd ulimit
testcmd test [
bindcmd bind
+wordexpcmd wordexp
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);
+}
diff --git a/bin/sh/expand.h b/bin/sh/expand.h
index 0fbd52a..9343bf3 100644
--- a/bin/sh/expand.h
+++ b/bin/sh/expand.h
@@ -65,3 +65,4 @@ void expari(int);
int patmatch(char *, char *, int);
void rmescapes(char *);
int casematch(union node *, char *);
+int wordexpcmd(int, char **);
OpenPOWER on IntegriCloud