1 /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
25 main (int argc, char *argv[])
32 while ((i = getopt (argc, argv, "bcdegmopqst")) != -1)
36 glob_flags |= GLOB_BRACE;
39 glob_flags |= GLOB_NOCHECK;
42 glob_flags |= GLOB_ONLYDIR;
45 glob_flags |= GLOB_NOESCAPE;
48 glob_flags |= GLOB_NOMAGIC;
51 glob_flags |= GLOB_MARK;
54 glob_flags |= GLOB_DOOFFS;
58 glob_flags |= GLOB_PERIOD;
64 glob_flags |= GLOB_NOSORT;
67 glob_flags |= GLOB_TILDE;
73 if (optind >= argc || chdir (argv[optind]))
77 if (optind + 1 >= argc)
80 /* Do a glob on each remaining argument. */
81 for (j = optind + 1; j < argc; j++) {
82 i = glob (argv[j], glob_flags, NULL, &g);
85 glob_flags |= GLOB_APPEND;
88 /* Was there an error? */
89 if (i == GLOB_NOSPACE)
90 puts ("GLOB_NOSPACE");
91 else if (i == GLOB_ABORTED)
92 puts ("GLOB_ABORTED");
93 else if (i == GLOB_NOMATCH)
94 puts ("GLOB_NOMATCH");
96 /* If we set an offset, fill in the first field. */
97 if (glob_flags & GLOB_DOOFFS)
98 g.gl_pathv[0] = (char *) "abc";
100 /* Print out the names. Unless otherwise specified, qoute them. */
103 for (i = 0; i < g.gl_pathc; ++i)
104 printf ("%s%s%s\n", quotes ? "`" : "", g.gl_pathv[i],