NAME
wwoorrddeexxpp - perform shell-style word expansions
SYNOPSIS
##iinncclluuddee <
int wwoorrddeexxpp(const char *restrict words, wordexpt *restrict pwordexp, int flags); void wwoorrddffrreeee(wordexpt *pwordexp);> DESCRIPTION
The wwoorrddeexxpp() function performs shell-style word expansion on words. It
places the list of words into the wewordv member of pwordexp and the number of words into wewordc.The flags argument (see BUGS) is the bitwise inclusive OR of any of the
following constants: WRDEAPPEND Append the words to those generated by a previous call to wwoorrddeexxpp().WRDEDOOFS As many NULL pointers as are specified by the weoffs mem-
ber of pwordexp are added to the front of wewordv. WRDENOCMD Disallow command substitution in words. See the note inBUGS before using this.
WRDEREUSE The pwordexp argument was passed to a previous successful call to wwoorrddeexxpp() but has not been passed to wwoorrddffrreeee(). The implementation may reuse the space allocated to it. WRDESHOWERR Do not redirect shell error messages to /dev/null. WRDEUNDEF Report error on an attempt to expand an undefined shell variable. The wordexpt structure is defined inas: typedef struct { sizet wewordc; /* count of words matched */ char **wewordv; /* pointer to list of words */ sizet weoffs; /* slots to reserve in wewordv */ } wordexpt; The wwoorrddffrreeee() function frees the memory allocated by wwoorrddeexxpp(). RETURN VALUES
The wwoorrddeexxpp() function returns zero if successful, otherwise it returns one of the following error codes: WRDEBADCHAR The words argument contains one of the following unquoted characters:, `|', `&', `;', `<', `>', `(', `)', `{', `}'. WRDEBADVAL An attempt was made to expand an undefined shell variable and WRDEUNDEF is set in flags. WRDECMDSUB An attempt was made to use command substitution and WRDENOCMD is set in flags. WRDENOSPACE Not enough memory to store the result. WRDESYNTAX Shell syntax error in words. The wwoorrddffrreeee() function returns no value. EEXXAAMMPPLLEESS Invoke the editor on all .c files in the current directory and /etc/motd (error checking omitted): wordexpt pwordexp; wordexp("${EDITOR:-vi} *.c /etc/motd", &pwordexp, 0);
execvp(pwordexp->wewordv[0], pwordexp->wewordv);
SEE ALSO
sh(1), fnmatch(3), glob(3), popen(3), system(3)BUGS
This version of wwoorrkkeexxpp() ignores the value of the flags argument. COPYRIGHTCopyright 1995-2002 University Corporation for Atmospheric
Research/Unidata Portions of this software were developed by the Unidata Program at the University Corporation for Atmospheric Research. BSD December 27, 2002 BSD