The
wordexp() function performs shell-style word expansion on
words and places the list of expanded words into the structure pointed to by
pwordexp.
The
flags argument is the bitwise inclusive OR of any of the following constants:
WRDE_APPEND
Append the words to those generated by a previous call to wordexp().
WRDE_DOOFFS
As many NULL pointers as are specified by the we_offs member of we are added to the front of we_wordv.
WRDE_NOCMD
Disallow command substitution in
words. See the note in
BUGS before using this.
WRDE_REUSE
The we argument was passed to a previous successful call to wordexp() but has not been passed to wordfree(). The implementation may reuse the space allocated to it.
WRDE_SHOWERR
Do not redirect shell error messages to /dev/null.
WRDE_UNDEF
Report error on an attempt to expand an undefined shell variable.
The structure type
wordexp_t includes the following members:
size_t we_wordc
char **we_wordv
size_t we_offs
The
we_wordc member is the count of generated words.
The
we_wordv member points to a list of pointers to expanded words.
The
we_offs member is the number of slots to reserve at the beginning of the
we_wordv member.
It is the caller's responsibility to allocate the storage pointed to by
pwordexp. The
wordexp() function allocates other space as needed, including memory pointed to by the
we_wordv member.
The
wordfree() function frees the memory allocated by
wordexp().