wordexp(3) Library Functions Manual wordexp(3) wordexp, wordfree - posix LIBRARY Standard C library (libc, -lc) #include int wordexp(const char *restrict s, wordexp_t *restrict p, int flags); void wordfree(wordexp_t *p); glibc (. feature_test_macros(7)): wordexp(), wordfree(): _XOPEN_SOURCE wordexp() s , , , p. wordexp_t -- , , , we_wordc, we_wordv we_offs. we_wordc size_t s. we_wordv char ** . we_offs size_t ( flags, . ) we_wordv, NULL. wordfree() . , , , we_wordv , . (. sh(1)) , s , . , |, &, ;, <, >, (, ), {, } . s , #, , , , , # . The expansion done consists of the following stages: tilde expansion (replacing ~user by user's home directory), variable substitution (replacing $FOO by the value of the environment variable FOO), command substitution (replacing $(command) or `command` by the output of command), arithmetic expansion, field splitting, wildcard expansion, quote removal. ($@, $*, $#, $?, $-, $$, $!, $0) . Field splitting is done using the environment variable $IFS. If it is not set, the field separators are space, tab, and newline. we_wordv NULL. flag : WRDE_APPEND , . WRDE_DOOFFS we_offs NULL we_wordv ( we_wordc). WRDE_NOCMD . WRDE_REUSE p wordexp(), wordfree() . . WRDE_SHOWERR , stderr /dev/null. stderr. WRDE_UNDEF , . On success, wordexp() returns 0. On failure, wordexp() returns one of the following nonzero values: WRDE_BADCHAR |, &, ;, <, >, (, ), {, }. WRDE_BADVAL WRDE_UNDEF. WRDE_CMDSUB , WRDE_NOCMD, . WRDE_NOSPACE . WRDE_SYNTAX , . attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |wordexp() | | MT-Unsafe race:utent | | | | const:env env sig:ALRM | | | | timer locale | +----------------------------+----------------------------------------------------------+--------------------------+ |wordfree() | | MT-Safe | +----------------------------+----------------------------------------------------------+--------------------------+ utent race:utent , setutent(3), getutent(3) endutent(3) , . wordexp(), race:utent . POSIX.1-2008. POSIX.1-2001. glibc 2.1. <>. #include #include #include int main(void) { wordexp_t p; char **w; wordexp("[a-c]*.c", &p, 0); w = p.we_wordv; for (size_t i = 0; i < p.we_wordc; i++) printf("%s\n", w[i]); wordfree(&p); exit(EXIT_SUCCESS); } . fnmatch(3), glob(3) Azamat Hackimov Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . wordexp(3)