Open System Services Library Calls Reference Manual (G06.28+, H06.05+)
OSS Library Calls (w - z) wordexp(3)
NAME
wordexp - Expands tokens from a stream of words
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossesrl
H-series OSS processes: /G/system/zdllnnn/zossedll
SYNOPSIS
#include <wordexp.h>
int wordexp(
const char *words,
wordexp_t *pwordexp,
int flags);
PARAMETERS
words Specifies the string containing the tokens to be expanded.
pwordexp Contains a pointer to a wordexp_t structure.
flags Contains a bit flag specifying the configurable aspects of the wordexp() func-
tion.
DESCRIPTION
The wordexp() function performs word expansions equivalent to the word expansion that would
be performed by the shell if the contents of the words parameter were arguments on the com-
mand line. The list of expanded words is placed in the structure pointed to by the pwordexp
parameter.
The words parameter cannot contain:
• An unquoted newline character
• Any of the unquoted shell special characters |, &, ;, <,or>, except in the case of com-
mand substitution
• Unquoted parentheses or braces, except in the case of command or variable substitution
If the words parameter contains an unquoted # (number sign) comment character that is the
beginning of a token, the wordexp() function might treat the comment character as a regular
character or might interpret it as a comment indicator and ignore the remainder of the expression
in the words parameter.
The wordexp() function allows an application to perform all of the shell’s expansions on a word
or words obtained from a user. For example, if the application prompts for a filename (or a list of
filenames) and then uses the wordexp() function to process the input, the user could respond
with anything that would be valid as input to the shell.
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.
527187-007 Hewlett-Packard Company 8−53