All the functions, constants and data types for word expansion are declared in the header file `wordexp.h'.
Word expansion produces a vector of words (strings). To return this
wordexp uses a special data type,
is a structure. You pass
wordexp the address of the structure,
and it fills in the structure's fields to tell you about the results.
we_wordvfield. Unlike the other fields, this is always an input to
wordexp, rather than an output from it. If you use a nonzero offset, then that many elements at the beginning of the vector are left empty. (The
wordexpfunction fills them with null pointers.) The
we_offsfield is meaningful only if you use the
WRDE_DOOFFSflag. Otherwise, the offset is always zero regardless of what is in this field, and the first real element comes at the beginning of the vector.
*word-vector-ptr. The argument flags is a combination of bit flags; see section Flags for Word Expansion, for details of the flags.
You shouldn't use any of the characters `|&;<>' in the string
words unless they are quoted; likewise for newline. If you use
these characters unquoted, you will get the
code. Don't use parentheses or braces unless they are quoted or part of
a word expansion construct. If you use quotation characters `'"`',
they should come in pairs that balance.
The results of word expansion are a sequence of words. The function
wordexp allocates a string for each resulting word, then
allocates a vector of type
char ** to store the addresses of
these strings. The last element of the vector is a null pointer.
This vector is called the word vector.
To return this vector,
wordexp stores both its address and its
length (number of elements, not counting the terminating null pointer)
wordexp succeeds, it returns 0. Otherwise, it returns one
of these error codes:
WRDE_UNDEFto forbid such references.
WRDE_NOCMDto forbid command substitution.
wordexpcan store part of the results--as much as it could allocate room for.
*word-vector-ptrpoints to. This does not free the structure
*word-vector-ptritself--only the other data it points to.
Go to the first, previous, next, last section, table of contents.