SYNOPSIS
#include <wordexp.h>
int wordexp(const char *words, wordexp_t *pwordexp, int flags);
void wordfree(wordexp_t *pwordexp);
DESCRIPTION
The
The expansion of words is the same as that performed by sh if words were arguments to a utility on a sh command line.
words cannot contain an unquoted newline or any of the following special characters:
| & ; < >
except in the context of command substitution.
words may also not contain unquoted parentheses or braces,
except in the context of command or variable substitution.
If words contains an unquoted comment character (#)
that begins a token,
The
The caller must allocate the storage pointed to by pwordexp;
however,
The flags argument controls the behavior of
- WRDE_APPEND
-
Appends words to those generated by previous
wordexp() calls with the same pwordexp argument. - WRDE_DOOFFS
-
Use the we_offs member of pwordexp to specify the number of null pointers to add to the beginning of the we_wordv member of pwordexp. In other words, the we_wordv member points to we_offs null pointers, followed by wordc word pointers, followed by a null pointer.
- WRDE_NOCMD
-
Fail if command substitution is requested.
- WRDE_REUSE
-
The pwordexp argument was passed to a previous successful
wordexp() call, and has not been passed towordfree() . The result is the same as if the application calledwordfree() followed bywordexp() without WRDE_REUSE. - WRDE_SHOWERR
-
Do not redirect the standard error stream. Normally,
wordexp() redirects any output on the standard error stream generated when executing utilities during command substitution to /dev/null. - WRDE_UNDEF
-
Report an error on an attempt to expand an undefined shell variable.
The
PARAMETERS
- flags
-
Contains a bitwise-OR value that controls the behavior of
wordexp() . - pwordexp
-
Points to a wordexp_t structure that contains the expanded words.
- words
-
Points to the string on which word expansion is to be performed.
RETURN VALUES
The
On success,
- WRDE_BADCHAR
-
An unquoted metacharacter appeared in the wrong place.
- WRDE_BADVAL
-
There was an undefined environment variable reference with the WRDE_UNDEF flag set.
- WRDE_CMDSUB
-
Command substitution was requested with the WRDE_NOCMD flag set.
- WRDE_NOSPACE
-
The process ran out of memory.
- WRDE_SYNTAX
-
There was a sh syntax error.
CONFORMANCE
POSIX.2
MULTITHREAD SAFETY LEVEL
Unsafe.
PORTING ISSUES
None.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Commands:
- sh
PTC MKS Toolkit 10.5 Documentation Build 40.