Manual Pages for UNIX Darwin command on man wordexp
MyWebUniversity

Manual Pages for UNIX Darwin command on man wordexp

WORDEXP(3) BSD Library Functions Manual WORDEXP(3)

NAME

wwoorrddeexxpp - perform shell-style word expansions

SYNOPSIS

##iinncclluuddee <>

int

wwoorrddeexxpp(const char * restrict words, wordexpt * restrict we, int flags);

void

wwoorrddffrreeee(wordexpt *we);

DESCRIPTION

The wwoorrddeexxpp() function performs shell-style word expansion on words and

places the list of words into the wewordv member of we, 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 we are added to the front of wewordv. WRDENOCMD Disallow command substitution in words. See the note in

BUGS before using this.

WRDEREUSE The we 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 in as:

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 we;

wordexp("${EDITOR:-vi} *.c /etc/motd", &we, 0);

execvp(we->wewordv[0], we->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. COPYRIGHT

Copyright 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




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™