www.delorie.com/gnu/docs/glibc/libc_160.html   search  
 
Buy the book!


The GNU C Library

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.4 Shell-Style Word Expansion

Word expansion means the process of splitting a string into words and substituting for variables, commands, and wildcards just as the shell does.

For example, when you write `ls -l foo.c', this string is split into three separate words---`ls', `-l' and `foo.c'. This is the most basic function of word expansion.

When you write `ls *.c', this can become many words, because the word `*.c' can be replaced with any number of file names. This is called wildcard expansion, and it is also a part of word expansion.

When you use `echo $PATH' to print your path, you are taking advantage of variable substitution, which is also part of word expansion.

Ordinary programs can perform word expansion just like the shell by calling the library function wordexp.

10.4.1 The Stages of Word Expansion  What word expansion does to a string.
10.4.2 Calling wordexp  How to call wordexp.
10.4.3 Flags for Word Expansion  Options you can enable in wordexp.
10.4.4 wordexp Example  A sample program that does word expansion.
10.4.5 Details of Tilde Expansion  Details of how tilde expansion works.
10.4.6 Details of Variable Substitution  Different types of variable substitution.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003