Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
wordexp(3) OSS Library Calls Reference Manual
The wordexp() function stores the number of generated words and a pointer to a list of pointers
to these words in the structure pointed to by the pwordexp parameter. Each field created during
the field splitting or pathname expansion is a separate word in the list pointed to by the pwordexp
parameter. The first pointer after the last token in the list is a null pointer. The expansion of spe-
cial parameters *, @, #, ?, -, $, !, and 0 is unspecified.
The words are expanded in the following order:
1. Tilde expansion is performed first.
2. Parameter expansion, command substitution, and arithmetic expansion are performed
next, from beginning to end.
3. Field splitting is then performed on fields generated by Step 2, unless the IFS (Input Field
Separators) is full.
4. Pathname expansion is performed, unless the set -f command is in effect.
5. Quotation-mark removal is always performed last.
The wordexp_t structure is allocated by the caller, but memory to contain the expanded tokens is
allocated by the wordexp( ) function and added to the structure as needed.
The flags Parameter
The value of the flags parameter is the bitwise inclusive OR of the following constants, which are
defined in the wordexp.h header file:
WRDE_APPEND
Appends words generated by this call to those generated by a previous call to the
wordexp() function.
WRDE_DOOFFS
Makes use of the we_offs field of the wordexp_t structure. If the
WRDE_DOOFFS flag is set, the we_offs field is used to specify the number of
null pointers to add to the beginning of the list of pointers pointed to by the
we_wordv field. If the WRDE_DOOFFS flag is not set in the first call to the
wordexp() function with a pwordexp parameter, it should not be set in subse-
quent calls to the wordexp() function with a pwordexp parameter.
WRDE_NOCMD
Fails if command substitution is requested.
WRDE_REUSE
Can reuse previously allocated memory, because the pwordexp parameter was
passed to a previous successful call to the wordexp() function. Therefore, the
memory previously allocated might be reused.
WRDE_SHOWERR
Does not redirect the standard error file to /dev/null.
WRDE_UNDEF
Reports an error on an attempt to expand an undefined shell variable.
The WRDE_ APPEND flag can be used to append a new set of words to those generated by a
previous call to the wordexp( ) function. The following rules apply when two or more calls to the
wordexp() function are made with the same value of the
pwordexp parameter
and
without inter-
vening calls to the wordfree( ) function:
8−70 Hewlett-Packard Company 527187-017