From: Peter Avalos Date: Sun, 7 Jan 2007 08:26:55 +0000 (+0000) Subject: Add the "wordexp" shell built-in command. X-Git-Tag: v2.0.1~3806 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/d13d0ee2799f86ccdfaa029206fcce8b01633763 Add the "wordexp" shell built-in command. Obtained-from: FreeBSD --- diff --git a/bin/sh/builtins.def b/bin/sh/builtins.def index 2e4b103f73..f2759ea229 100644 --- a/bin/sh/builtins.def +++ b/bin/sh/builtins.def @@ -36,8 +36,8 @@ # SUCH DAMAGE. # # @(#)builtins.def 8.4 (Berkeley) 5/4/95 -# $FreeBSD: src/bin/sh/builtins.def,v 1.7.2.2 2002/08/27 01:36:28 tjr Exp $ -# $DragonFly: src/bin/sh/builtins.def,v 1.4 2007/01/07 02:52:07 pavalos Exp $ +# $FreeBSD: src/bin/sh/builtins.def,v 1.19 2006/04/02 18:43:33 stefanf Exp $ +# $DragonFly: src/bin/sh/builtins.def,v 1.5 2007/01/07 08:26:55 pavalos Exp $ # # This file lists all the builtin commands. The first column is the name @@ -92,3 +92,4 @@ umaskcmd umask unaliascmd unalias unsetcmd -s unset waitcmd wait +wordexpcmd wordexp diff --git a/bin/sh/expand.c b/bin/sh/expand.c index 2bc389af0f..79ee2125fa 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -35,7 +35,7 @@ * * @(#)expand.c 8.5 (Berkeley) 5/15/95 * $FreeBSD: src/bin/sh/expand.c,v 1.31.2.5 2003/01/17 07:44:01 tjr Exp $ - * $DragonFly: src/bin/sh/expand.c,v 1.7 2006/09/28 22:29:44 pavalos Exp $ + * $DragonFly: src/bin/sh/expand.c,v 1.8 2007/01/07 08:26:55 pavalos Exp $ */ #include @@ -48,6 +48,7 @@ #include #include #include +#include /* * Routines to expand arguments to commands. We have to deal with @@ -1518,3 +1519,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 e9312a168c..1f5f28b167 100644 --- a/bin/sh/expand.h +++ b/bin/sh/expand.h @@ -34,8 +34,8 @@ * SUCH DAMAGE. * * @(#)expand.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/expand.h,v 1.9.2.1 2002/07/19 04:38:51 tjr Exp $ - * $DragonFly: src/bin/sh/expand.h,v 1.2 2003/06/17 04:22:50 dillon Exp $ + * $FreeBSD: src/bin/sh/expand.h,v 1.12 2004/04/06 20:06:51 markm Exp $ + * $DragonFly: src/bin/sh/expand.h,v 1.3 2007/01/07 08:26:55 pavalos Exp $ */ struct strlist { @@ -66,3 +66,4 @@ void expari(int); int patmatch(char *, char *, int); void rmescapes(char *); int casematch(union node *, char *); +int wordexpcmd(int, char **);