1 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl)
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 .\" GNU General Public License for more details.
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
23 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
24 .\" all rights reserved.
25 .\" Translated Sun Sep 12 05:05:19 JST 2004
26 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
28 .TH WORDEXP 3 2008-07-14 "" "Linux Programmer's Manual"
30 wordexp, wordfree \- posix ¥·¥§¥ë¤Î¤è¤¦¤Ëñ¸ì¤ÎŸ³«¤ò¹Ô¤¦
32 .B "#include <wordexp.h>"
34 .BI "int wordexp(const char *" s ", wordexp_t *" p ", int " flags );
36 .BI "void wordfree(wordexp_t *" p );
39 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
40 .RB ( feature_test_macros (7)
50 ¤Ï¥·¥§¥ë¤Î¤è¤¦¤Ëʸ»úÎó
54 ¤Ç»Ø¤·¼¨¤¹¹½Â¤ÂΤ˷ë²Ì¤òÊÖ¤¹¡£
57 ¤Ï¾¯¤Ê¤¯¤È¤â¥Õ¥£¡¼¥ë¥É
68 ¤òŸ³«¤·¤¿·ë²Ì¤Ëñ¸ì¤¬¤¤¤¯¤Ä¤¢¤ë¤«¤òɽ¤¹¡£
73 ¤Ç¤¢¤ê¡¢¸«¤Ä¤«¤Ã¤¿Ã±¸ì¤ÎÇÛÎó¤ò»Ø¤·¼¨¤¹¡£
79 ÇÛÎó¤Ë¤¢¤ë½é´üÍ×ÁǤΤ¦¤Á¤¤¤¯¤Ä¤¬
80 NULL ¤ÇËä¤á¤é¤ì¤ë¤Ù¤¤«¤òɽ¤¹¤Î¤Ë»È¤ï¤ì¤¿¤ê¤¹¤ë
82 ¤Ë¤è¤ê·èÄꤵ¤ì¤ë¡£²¼µ¤ò»²¾È¡£)¡£
86 ¤Ï³ä¤êÅö¤Æ¤¿¥á¥â¥ê¤òºÆÅÙ²òÊü¤¹¤ë¡£
87 ¤è¤êÀµ³Î¤Ë¤¤¤¦¤È¡¢¤³¤Î´Ø¿ô¤Ï¤½¤Î°ú¤¿ô¤ò²òÊü¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢
90 ¤È¤½¤ì¤¬»Ø¤·¼¨¤¹Ê¸»úÎó¤ò²òÊü¤¹¤ë¡£
92 ¤³¤ÎŸ³«¤Ï¥·¥§¥ë¤Ë¤è¤ë¥³¥Þ¥ó¥É¤Î¥Ñ¥é¥á¡¼¥¿¤ÎŸ³«
94 ¤ò»²¾È) ¤ÈƱ¤¸¤Ç¤¢¤ë¤Î¤Ç¡¢Ê¸»úÎó
96 ¤Ï¥·¥§¥ë¥³¥Þ¥ó¥É¥Ñ¥é¥á¡¼¥¿¤ÇÉÔÀµ¤È¤µ¤ì¤ëʸ»ú¤ò´Þ¤ó¤Ç¤Ï¤Ê¤é¤Ê¤¤¡£
97 Æä˥¨¥¹¥±¡¼¥×¤µ¤ì¤Æ¤¤¤Ê¤¤²þ¹Ô¡¢|, &, ;, <, >, (, ), {, } ʸ»ú¤ò
98 ¥³¥Þ¥ó¥ÉÃÖ´¹¤ä¥Ñ¥é¥á¡¼¥¿ÃÖ´¹¤Î¾ìḬ̀ʳ°¤Ë´Þ¤á¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
102 ¤Ë¥¯¥©¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥³¥á¥ó¥Èʸ»ú # ¤Ç»Ï¤Þ¤ëñ¸ì¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
103 ¤½¤Îñ¸ì¤È¤½¤ì°Ê¹ß¤Îñ¸ì¤¬Ìµ»ë¤µ¤ì¤ë¤«¡¢
104 ¤½¤ì¤È¤â # ¤¬¥³¥á¥ó¥Èʸ»ú¤È¤·¤Æ°·¤ï¤Ê¤¤¤«¤Ï¡¢µ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
106 ¼Â¹Ô¤µ¤ì¤ëŸ³«¤Ï¡¢°Ê²¼¤ÎÃʳ¬¤Ç¹½À®¤µ¤ì¤ë:
107 ¥Á¥ë¥ÀŸ³« (~user ¤ò user ¤Î¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê¤ËÃÖ¤´¹¤¨¤ë)¡¢
108 ÊÑ¿ôŸ³« ($FOO ¤ò´Ä¶ÊÑ¿ô FOO ¤ÎÃͤËÃÖ¤´¹¤¨¤ë)¡¢
109 ¥³¥Þ¥ó¥ÉŸ³« ($(command) ¤Þ¤¿¤Ï \`command\` ¤ò command ¤Î½ÐÎϤÇÃÖ¤´¹¤¨¤ë)¡¢
110 »»½ÑŸ³«¡¢¥Õ¥£¡¼¥ë¥Éʬ³ä¡¢¥ï¥¤¥ë¥É¥«¡¼¥ÉŸ³«¡¢¥¯¥©¡¼¥È¤Î½üµî¡£
112 Æüì¤Ê¥Ñ¥é¥á¡¼¥¿ ($@, $*, $#, $?, $\-, $$, $!, $0) ¤Î
113 Ÿ³«·ë²Ì¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
115 ¥Õ¥£¡¼¥ë¥Éʬ³ä¤Ï´Ä¶ÊÑ¿ô $IFS ¤òÍѤ¤¤Æ¹Ô¤ï¤ì¤ë¡£
116 ¤³¤Î´Ä¶ÊÑ¿ô¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
117 ¥Õ¥£¡¼¥ë¥É¶èÀÚ¤êʸ»ú¤Ï¥¹¥Ú¡¼¥¹¡¦¥¿¥Ö¡¦²þ¹Ô¤Ç¤¢¤ë¡£
121 ¤Ï¸«¤Ä¤«¤Ã¤¿Ã±¸ì¤ò¤ò´Þ¤ß¡¢ºÇ¸å¤Ë NULL ¤¬Â³¤¯¡£
124 °ú¤¿ô¤Ï°Ê²¼¤ÎÃͤΥӥåÈÊñ´ÞŪ OR ¤Ç¤¢¤ë:
127 ¸«¤Ä¤«¤Ã¤¿Ã±¸ì¤òÁ°²ó¤Î¸Æ¤Ó½Ð¤··ë²Ì¤ÎÇÛÎó¤ËÄɲ乤롣
134 ¤ËÁÞÆþ¤¹¤ë (¤³¤ì¤é¤ÏÊÖ¤µ¤ì¤ë
136 ¤Ë¤Ï¥«¥¦¥ó¥È¤µ¤ì¤Ê¤¤)¡£
139 ¥³¥Þ¥ó¥ÉÃÖ´¹¤ò¹Ô¤ï¤Ê¤¤¡£
146 ¤Î¸Æ¤Ó½Ð¤··ë²Ì¤Ç¤¢¤ê¡¢
148 ¤¬ (¤Þ¤À) ¸Æ¤Ó½Ð¤µ¤ì¤Ê¤¤¡£
149 ³ä¤êÅö¤Æ¤é¤ì¤¿Îΰè¤òºÆÍøÍѤ¹¤ë¡£
152 Ä̾ï¤Ï¥³¥Þ¥ó¥ÉÃÖ´¹¤Î¤È¤¤Ë
156 ¤Ë¥ê¥À¥¤¥ì¥¯¥È¤µ¤ì¤ë¡£
159 ¤ò¥ê¥À¥¤¥ì¥¯¥È¤·¤Ê¤¤¤è¤¦¤Ë»ØÄꤹ¤ë¡£
162 ̤ÄêµÁ¤Î¥·¥§¥ëÊÑ¿ô¤òŸ³«¤·¤è¤¦¤È¤·¤¿¾ì¹ç¤Ë¡¢¥¨¥é¡¼¤È¤·¤Æ°·¤¦¡£
164 À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£
165 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï°Ê²¼¤Î 5 ¤Ä¤ÎÃͤΤ¦¤Á¤Î 1 ¤Ä¤¬ÊÖ¤µ¤ì¤ë¡£
168 ²þ¹Ô¤Þ¤¿¤Ï |, &, ;, <, >, (, ), {, } ¤Î¤¦¤Á¤Î 1 ¤Ä¤¬ÉÔÀµ¤Ë½Ð¸½¤·¤¿¡£
171 ̤ÄêµÁ¤Î¥·¥§¥ëÊÑ¿ô¤¬»²¾È¤µ¤ì¡¢¤«¤Ä
173 ¥Õ¥é¥°¤Ç¤³¤ì¤ò¥¨¥é¡¼¤È¤·¤Æ°·¤¦¤è¤¦¤Ë»Ø¼¨¤µ¤ì¤Æ¤¤¤ë¡£
176 ¥³¥Þ¥ó¥ÉÃÖ´¹¤¬µ¯¤³¤ê¡¢¤«¤Ä
178 ¥Õ¥é¥°¤Ç¤³¤ì¤ò¥¨¥é¡¼¤È¤·¤Æ°·¤¦¤è¤¦¤Ë»Ø¼¨¤µ¤ì¤Æ¤¤¤ë¡£
184 Âбþ¤¹¤ë³ç¸Ì¤¬¤Ê¤¤¡¢¥¯¥©¡¼¥È¤¬¹çÃפ·¤Ê¤¤¤È¤¤¤Ã¤¿¡¢
190 ¤Ï¡¢¥Ð¡¼¥¸¥ç¥ó 2.1 °Ê¹ß¤Î glibc ¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¡£
194 °Ê²¼¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Î½ÐÎϤϤÀ¤¤¤¿¤¤ "ls [a-c]*.c" ¤ÈƱ¤¸¤Ë¤Ê¤ë¡£
202 main(int argc, char **argv)
208 wordexp("[a-c]*.c", &p, 0);
210 for (i = 0; i < p.we_wordc; i++)
211 printf("%s\en", w[i]);