Add the "wordexp" shell built-in command which will be used to implement
the POSIX wordexp() function.
This commit is contained in:
parent
326b4d74c4
commit
2c25061f18
@ -93,3 +93,4 @@ aliascmd alias
|
||||
ulimitcmd ulimit
|
||||
testcmd test [
|
||||
bindcmd bind
|
||||
wordexpcmd wordexp
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -65,3 +65,4 @@ void expari(int);
|
||||
int patmatch(char *, char *, int);
|
||||
void rmescapes(char *);
|
||||
int casematch(union node *, char *);
|
||||
int wordexpcmd(int, char **);
|
||||
|
Loading…
Reference in New Issue
Block a user