dd: synchronize output after write errors
[coreutils.git] / src / test.c
blobf154199ceb9fd1ad2b3af4e748a6f211333bfddc
1 /* GNU test program (ksb and mjb) */
3 /* Modified to run with the GNU shell by bfox. */
5 /* Copyright (C) 1987-2022 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 /* Define TEST_STANDALONE to get the /bin/test version. Otherwise, you get
21 the shell builtin version. */
23 /* Without this pragma, gcc 4.6.2 20111027 mistakenly suggests that
24 the advance function might be candidate for attribute 'pure'. */
25 #if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
26 # pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
27 #endif
29 #include <config.h>
30 #include <stdio.h>
31 #include <sys/types.h>
33 #define TEST_STANDALONE 1
35 #ifndef LBRACKET
36 # define LBRACKET 0
37 #endif
39 /* The official name of this program (e.g., no 'g' prefix). */
40 #if LBRACKET
41 # define PROGRAM_NAME "["
42 #else
43 # define PROGRAM_NAME "test"
44 #endif
46 #include "system.h"
47 #include "quote.h"
48 #include "stat-time.h"
49 #include "strnumcmp.h"
51 #include <stdarg.h>
52 #include "verror.h"
54 #if HAVE_SYS_PARAM_H
55 # include <sys/param.h>
56 #endif
58 /* Exit status for syntax errors, etc. */
59 enum { TEST_TRUE, TEST_FALSE, TEST_FAILURE };
61 #if defined TEST_STANDALONE
62 # define test_exit(val) exit (val)
63 # define test_main_return(val) return val
64 #else
65 static jmp_buf test_exit_buf;
66 static int test_error_return = 0;
67 # define test_exit(val) test_error_return = val, longjmp (test_exit_buf, 1)
68 # define test_main_return(val) test_exit (val)
69 #endif /* !TEST_STANDALONE */
71 static int pos; /* The offset of the current argument in ARGV. */
72 static int argc; /* The number of arguments present in ARGV. */
73 static char **argv; /* The argument list. */
75 static bool unary_operator (void);
76 static bool binary_operator (bool);
77 static bool two_arguments (void);
78 static bool three_arguments (void);
79 static bool posixtest (int);
81 static bool expr (void);
82 static bool term (void);
83 static bool and (void);
84 static bool or (void);
86 static void beyond (void);
88 ATTRIBUTE_FORMAT ((printf, 1, 2))
89 static _Noreturn void
90 test_syntax_error (char const *format, ...)
92 va_list ap;
93 va_start (ap, format);
94 verror (0, 0, format, ap);
95 test_exit (TEST_FAILURE);
98 /* Increment our position in the argument list. Check that we're not
99 past the end of the argument list. This check is suppressed if the
100 argument is false. */
102 static void
103 advance (bool f)
105 ++pos;
107 if (f && pos >= argc)
108 beyond ();
111 static void
112 unary_advance (void)
114 advance (true);
115 ++pos;
119 * beyond - call when we're beyond the end of the argument list (an
120 * error condition)
122 static void
123 beyond (void)
125 test_syntax_error (_("missing argument after %s"), quote (argv[argc - 1]));
128 /* If the characters pointed to by STRING constitute a valid number,
129 return a pointer to the start of the number, skipping any blanks or
130 leading '+'. Otherwise, report an error and exit. */
131 static char const *
132 find_int (char const *string)
134 char const *p;
135 char const *number_start;
137 for (p = string; isblank (to_uchar (*p)); p++)
138 continue;
140 if (*p == '+')
142 p++;
143 number_start = p;
145 else
147 number_start = p;
148 p += (*p == '-');
151 if (ISDIGIT (*p++))
153 while (ISDIGIT (*p))
154 p++;
155 while (isblank (to_uchar (*p)))
156 p++;
157 if (!*p)
158 return number_start;
161 test_syntax_error (_("invalid integer %s"), quote (string));
164 /* Find the modification time of FILE, and stuff it into *MTIME.
165 Return true if successful. */
166 static bool
167 get_mtime (char const *filename, struct timespec *mtime)
169 struct stat finfo;
170 bool ok = (stat (filename, &finfo) == 0);
171 #ifdef lint
172 static struct timespec const zero;
173 *mtime = zero;
174 #endif
175 if (ok)
176 *mtime = get_stat_mtime (&finfo);
177 return ok;
180 /* Return true if S is one of the test command's binary operators. */
181 static bool
182 binop (char const *s)
184 return ((STREQ (s, "=")) || (STREQ (s, "!=")) || (STREQ (s, "==")) ||
185 (STREQ (s, "-nt")) ||
186 (STREQ (s, "-ot")) || (STREQ (s, "-ef")) || (STREQ (s, "-eq")) ||
187 (STREQ (s, "-ne")) || (STREQ (s, "-lt")) || (STREQ (s, "-le")) ||
188 (STREQ (s, "-gt")) || (STREQ (s, "-ge")));
192 * term - parse a term and return 1 or 0 depending on whether the term
193 * evaluates to true or false, respectively.
195 * term ::=
196 * '-'('h'|'d'|'f'|'r'|'s'|'w'|'c'|'b'|'p'|'u'|'g'|'k') filename
197 * '-'('L'|'x') filename
198 * '-t' int
199 * '-'('z'|'n') string
200 * string
201 * string ('!='|'=') string
202 * <int> '-'(eq|ne|le|lt|ge|gt) <int>
203 * file '-'(nt|ot|ef) file
204 * '(' <expr> ')'
205 * int ::=
206 * '-l' string
207 * positive and negative integers
209 static bool
210 term (void)
212 bool value;
213 bool negated = false;
215 /* Deal with leading 'not's. */
216 while (pos < argc && argv[pos][0] == '!' && argv[pos][1] == '\0')
218 advance (true);
219 negated = !negated;
222 if (pos >= argc)
223 beyond ();
225 /* A paren-bracketed argument. */
226 if (argv[pos][0] == '(' && argv[pos][1] == '\0')
228 int nargs;
230 advance (true);
232 for (nargs = 1;
233 pos + nargs < argc && ! STREQ (argv[pos + nargs], ")");
234 nargs++)
235 if (nargs == 4)
237 nargs = argc - pos;
238 break;
241 value = posixtest (nargs);
242 if (argv[pos] == 0)
243 test_syntax_error (_("%s expected"), quote (")"));
244 else
245 if (argv[pos][0] != ')' || argv[pos][1])
246 test_syntax_error (_("%s expected, found %s"),
247 quote_n (0, ")"), quote_n (1, argv[pos]));
248 advance (false);
251 /* Are there enough arguments left that this could be dyadic? */
252 else if (4 <= argc - pos && STREQ (argv[pos], "-l") && binop (argv[pos + 2]))
253 value = binary_operator (true);
254 else if (3 <= argc - pos && binop (argv[pos + 1]))
255 value = binary_operator (false);
257 /* It might be a switch type argument. */
258 else if (argv[pos][0] == '-' && argv[pos][1] && argv[pos][2] == '\0')
259 value = unary_operator ();
260 else
262 value = (argv[pos][0] != '\0');
263 advance (false);
266 return negated ^ value;
269 static bool
270 binary_operator (bool l_is_l)
272 int op;
273 struct stat stat_buf, stat_spare;
274 /* Is the right integer expression of the form '-l string'? */
275 bool r_is_l;
277 if (l_is_l)
278 advance (false);
279 op = pos + 1;
281 if ((op < argc - 2) && STREQ (argv[op + 1], "-l"))
283 r_is_l = true;
284 advance (false);
286 else
287 r_is_l = false;
289 if (argv[op][0] == '-')
291 /* check for eq, nt, and stuff */
292 if ((((argv[op][1] == 'l' || argv[op][1] == 'g')
293 && (argv[op][2] == 'e' || argv[op][2] == 't'))
294 || (argv[op][1] == 'e' && argv[op][2] == 'q')
295 || (argv[op][1] == 'n' && argv[op][2] == 'e'))
296 && !argv[op][3])
298 char lbuf[INT_BUFSIZE_BOUND (uintmax_t)];
299 char rbuf[INT_BUFSIZE_BOUND (uintmax_t)];
300 char const *l = (l_is_l
301 ? umaxtostr (strlen (argv[op - 1]), lbuf)
302 : find_int (argv[op - 1]));
303 char const *r = (r_is_l
304 ? umaxtostr (strlen (argv[op + 2]), rbuf)
305 : find_int (argv[op + 1]));
306 int cmp = strintcmp (l, r);
307 bool xe_operator = (argv[op][2] == 'e');
308 pos += 3;
309 return (argv[op][1] == 'l' ? cmp < xe_operator
310 : argv[op][1] == 'g' ? cmp > - xe_operator
311 : (cmp != 0) == xe_operator);
314 switch (argv[op][1])
316 default:
317 break;
319 case 'n':
320 if (argv[op][2] == 't' && !argv[op][3])
322 /* nt - newer than */
323 struct timespec lt, rt;
324 bool le, re;
325 pos += 3;
326 if (l_is_l || r_is_l)
327 test_syntax_error (_("-nt does not accept -l"));
328 le = get_mtime (argv[op - 1], &lt);
329 re = get_mtime (argv[op + 1], &rt);
330 return le && (!re || timespec_cmp (lt, rt) > 0);
332 break;
334 case 'e':
335 if (argv[op][2] == 'f' && !argv[op][3])
337 /* ef - hard link? */
338 pos += 3;
339 if (l_is_l || r_is_l)
340 test_syntax_error (_("-ef does not accept -l"));
341 return (stat (argv[op - 1], &stat_buf) == 0
342 && stat (argv[op + 1], &stat_spare) == 0
343 && stat_buf.st_dev == stat_spare.st_dev
344 && stat_buf.st_ino == stat_spare.st_ino);
346 break;
348 case 'o':
349 if ('t' == argv[op][2] && '\000' == argv[op][3])
351 /* ot - older than */
352 struct timespec lt, rt;
353 bool le, re;
354 pos += 3;
355 if (l_is_l || r_is_l)
356 test_syntax_error (_("-ot does not accept -l"));
357 le = get_mtime (argv[op - 1], &lt);
358 re = get_mtime (argv[op + 1], &rt);
359 return re && (!le || timespec_cmp (lt, rt) < 0);
361 break;
364 /* FIXME: is this dead code? */
365 test_syntax_error (_("%s: unknown binary operator"), quote (argv[op]));
368 if (argv[op][0] == '='
369 && (!argv[op][1] || ((argv[op][1] == '=') && !argv[op][2])))
371 bool value = STREQ (argv[pos], argv[pos + 2]);
372 pos += 3;
373 return value;
376 if (STREQ (argv[op], "!="))
378 bool value = !STREQ (argv[pos], argv[pos + 2]);
379 pos += 3;
380 return value;
383 /* Not reached. */
384 abort ();
387 static bool
388 unary_operator (void)
390 struct stat stat_buf;
392 switch (argv[pos][1])
394 default:
395 test_syntax_error (_("%s: unary operator expected"), quote (argv[pos]));
396 return false;
398 /* All of the following unary operators use unary_advance (), which
399 checks to make sure that there is an argument, and then advances
400 pos right past it. This means that pos - 1 is the location of the
401 argument. */
403 case 'e': /* file exists in the file system? */
404 unary_advance ();
405 return stat (argv[pos - 1], &stat_buf) == 0;
407 case 'r': /* file is readable? */
408 unary_advance ();
409 return euidaccess (argv[pos - 1], R_OK) == 0;
411 case 'w': /* File is writable? */
412 unary_advance ();
413 return euidaccess (argv[pos - 1], W_OK) == 0;
415 case 'x': /* File is executable? */
416 unary_advance ();
417 return euidaccess (argv[pos - 1], X_OK) == 0;
419 case 'N': /* File exists and has been modified since it was last read? */
421 unary_advance ();
422 if (stat (argv[pos - 1], &stat_buf) != 0)
423 return false;
424 struct timespec atime = get_stat_atime (&stat_buf);
425 struct timespec mtime = get_stat_mtime (&stat_buf);
426 return (timespec_cmp (mtime, atime) > 0);
429 case 'O': /* File is owned by you? */
431 unary_advance ();
432 if (stat (argv[pos - 1], &stat_buf) != 0)
433 return false;
434 errno = 0;
435 uid_t euid = geteuid ();
436 uid_t NO_UID = -1;
437 return ! (euid == NO_UID && errno) && euid == stat_buf.st_uid;
440 case 'G': /* File is owned by your group? */
442 unary_advance ();
443 if (stat (argv[pos - 1], &stat_buf) != 0)
444 return false;
445 errno = 0;
446 gid_t egid = getegid ();
447 gid_t NO_GID = -1;
448 return ! (egid == NO_GID && errno) && egid == stat_buf.st_gid;
451 case 'f': /* File is a file? */
452 unary_advance ();
453 /* Under POSIX, -f is true if the given file exists
454 and is a regular file. */
455 return (stat (argv[pos - 1], &stat_buf) == 0
456 && S_ISREG (stat_buf.st_mode));
458 case 'd': /* File is a directory? */
459 unary_advance ();
460 return (stat (argv[pos - 1], &stat_buf) == 0
461 && S_ISDIR (stat_buf.st_mode));
463 case 's': /* File has something in it? */
464 unary_advance ();
465 return (stat (argv[pos - 1], &stat_buf) == 0
466 && 0 < stat_buf.st_size);
468 case 'S': /* File is a socket? */
469 unary_advance ();
470 return (stat (argv[pos - 1], &stat_buf) == 0
471 && S_ISSOCK (stat_buf.st_mode));
473 case 'c': /* File is character special? */
474 unary_advance ();
475 return (stat (argv[pos - 1], &stat_buf) == 0
476 && S_ISCHR (stat_buf.st_mode));
478 case 'b': /* File is block special? */
479 unary_advance ();
480 return (stat (argv[pos - 1], &stat_buf) == 0
481 && S_ISBLK (stat_buf.st_mode));
483 case 'p': /* File is a named pipe? */
484 unary_advance ();
485 return (stat (argv[pos - 1], &stat_buf) == 0
486 && S_ISFIFO (stat_buf.st_mode));
488 case 'L': /* Same as -h */
489 /*FALLTHROUGH*/
491 case 'h': /* File is a symbolic link? */
492 unary_advance ();
493 return (lstat (argv[pos - 1], &stat_buf) == 0
494 && S_ISLNK (stat_buf.st_mode));
496 case 'u': /* File is setuid? */
497 unary_advance ();
498 return (stat (argv[pos - 1], &stat_buf) == 0
499 && (stat_buf.st_mode & S_ISUID));
501 case 'g': /* File is setgid? */
502 unary_advance ();
503 return (stat (argv[pos - 1], &stat_buf) == 0
504 && (stat_buf.st_mode & S_ISGID));
506 case 'k': /* File has sticky bit set? */
507 unary_advance ();
508 return (stat (argv[pos - 1], &stat_buf) == 0
509 && (stat_buf.st_mode & S_ISVTX));
511 case 't': /* File (fd) is a terminal? */
513 long int fd;
514 char const *arg;
515 unary_advance ();
516 arg = find_int (argv[pos - 1]);
517 errno = 0;
518 fd = strtol (arg, NULL, 10);
519 return (errno != ERANGE && 0 <= fd && fd <= INT_MAX && isatty (fd));
522 case 'n': /* True if arg has some length. */
523 unary_advance ();
524 return argv[pos - 1][0] != 0;
526 case 'z': /* True if arg has no length. */
527 unary_advance ();
528 return argv[pos - 1][0] == '\0';
533 * and:
534 * term
535 * term '-a' and
537 static bool
538 and (void)
540 bool value = true;
542 while (true)
544 value &= term ();
545 if (! (pos < argc && STREQ (argv[pos], "-a")))
546 return value;
547 advance (false);
552 * or:
553 * and
554 * and '-o' or
556 static bool
557 or (void)
559 bool value = false;
561 while (true)
563 value |= and ();
564 if (! (pos < argc && STREQ (argv[pos], "-o")))
565 return value;
566 advance (false);
571 * expr:
572 * or
574 static bool
575 expr (void)
577 if (pos >= argc)
578 beyond ();
580 return or (); /* Same with this. */
583 static bool
584 one_argument (void)
586 return argv[pos++][0] != '\0';
589 static bool
590 two_arguments (void)
592 bool value;
594 if (STREQ (argv[pos], "!"))
596 advance (false);
597 value = ! one_argument ();
599 else if (argv[pos][0] == '-'
600 && argv[pos][1] != '\0'
601 && argv[pos][2] == '\0')
603 value = unary_operator ();
605 else
606 beyond ();
607 return (value);
610 static bool
611 three_arguments (void)
613 bool value;
615 if (binop (argv[pos + 1]))
616 value = binary_operator (false);
617 else if (STREQ (argv[pos], "!"))
619 advance (true);
620 value = !two_arguments ();
622 else if (STREQ (argv[pos], "(") && STREQ (argv[pos + 2], ")"))
624 advance (false);
625 value = one_argument ();
626 advance (false);
628 else if (STREQ (argv[pos + 1], "-a") || STREQ (argv[pos + 1], "-o"))
629 value = expr ();
630 else
631 test_syntax_error (_("%s: binary operator expected"),
632 quote (argv[pos + 1]));
633 return (value);
636 /* This is an implementation of a Posix.2 proposal by David Korn. */
637 static bool
638 posixtest (int nargs)
640 bool value;
642 switch (nargs)
644 case 1:
645 value = one_argument ();
646 break;
648 case 2:
649 value = two_arguments ();
650 break;
652 case 3:
653 value = three_arguments ();
654 break;
656 case 4:
657 if (STREQ (argv[pos], "!"))
659 advance (true);
660 value = !three_arguments ();
661 break;
663 if (STREQ (argv[pos], "(") && STREQ (argv[pos + 3], ")"))
665 advance (false);
666 value = two_arguments ();
667 advance (false);
668 break;
670 FALLTHROUGH;
671 case 5:
672 default:
673 if (nargs <= 0)
674 abort ();
675 value = expr ();
678 return (value);
681 #if defined TEST_STANDALONE
683 void
684 usage (int status)
686 if (status != EXIT_SUCCESS)
687 emit_try_help ();
688 else
690 fputs (_("\
691 Usage: test EXPRESSION\n\
692 or: test\n\
693 or: [ EXPRESSION ]\n\
694 or: [ ]\n\
695 or: [ OPTION\n\
696 "), stdout);
697 fputs (_("\
698 Exit with the status determined by EXPRESSION.\n\
700 "), stdout);
701 fputs (HELP_OPTION_DESCRIPTION, stdout);
702 fputs (VERSION_OPTION_DESCRIPTION, stdout);
703 fputs (_("\
705 An omitted EXPRESSION defaults to false. Otherwise,\n\
706 EXPRESSION is true or false and sets exit status. It is one of:\n\
707 "), stdout);
708 fputs (_("\
710 ( EXPRESSION ) EXPRESSION is true\n\
711 ! EXPRESSION EXPRESSION is false\n\
712 EXPRESSION1 -a EXPRESSION2 both EXPRESSION1 and EXPRESSION2 are true\n\
713 EXPRESSION1 -o EXPRESSION2 either EXPRESSION1 or EXPRESSION2 is true\n\
714 "), stdout);
715 fputs (_("\
717 -n STRING the length of STRING is nonzero\n\
718 STRING equivalent to -n STRING\n\
719 -z STRING the length of STRING is zero\n\
720 STRING1 = STRING2 the strings are equal\n\
721 STRING1 != STRING2 the strings are not equal\n\
722 "), stdout);
723 fputs (_("\
725 INTEGER1 -eq INTEGER2 INTEGER1 is equal to INTEGER2\n\
726 INTEGER1 -ge INTEGER2 INTEGER1 is greater than or equal to INTEGER2\n\
727 INTEGER1 -gt INTEGER2 INTEGER1 is greater than INTEGER2\n\
728 INTEGER1 -le INTEGER2 INTEGER1 is less than or equal to INTEGER2\n\
729 INTEGER1 -lt INTEGER2 INTEGER1 is less than INTEGER2\n\
730 INTEGER1 -ne INTEGER2 INTEGER1 is not equal to INTEGER2\n\
731 "), stdout);
732 fputs (_("\
734 FILE1 -ef FILE2 FILE1 and FILE2 have the same device and inode numbers\n\
735 FILE1 -nt FILE2 FILE1 is newer (modification date) than FILE2\n\
736 FILE1 -ot FILE2 FILE1 is older than FILE2\n\
737 "), stdout);
738 fputs (_("\
740 -b FILE FILE exists and is block special\n\
741 -c FILE FILE exists and is character special\n\
742 -d FILE FILE exists and is a directory\n\
743 -e FILE FILE exists\n\
744 "), stdout);
745 fputs (_("\
746 -f FILE FILE exists and is a regular file\n\
747 -g FILE FILE exists and is set-group-ID\n\
748 -G FILE FILE exists and is owned by the effective group ID\n\
749 -h FILE FILE exists and is a symbolic link (same as -L)\n\
750 -k FILE FILE exists and has its sticky bit set\n\
751 "), stdout);
752 fputs (_("\
753 -L FILE FILE exists and is a symbolic link (same as -h)\n\
754 -N FILE FILE exists and has been modified since it was last read\n\
755 -O FILE FILE exists and is owned by the effective user ID\n\
756 -p FILE FILE exists and is a named pipe\n\
757 -r FILE FILE exists and read permission is granted\n\
758 -s FILE FILE exists and has a size greater than zero\n\
759 "), stdout);
760 fputs (_("\
761 -S FILE FILE exists and is a socket\n\
762 -t FD file descriptor FD is opened on a terminal\n\
763 -u FILE FILE exists and its set-user-ID bit is set\n\
764 -w FILE FILE exists and write permission is granted\n\
765 -x FILE FILE exists and execute (or search) permission is granted\n\
766 "), stdout);
767 fputs (_("\
769 Except for -h and -L, all FILE-related tests dereference symbolic links.\n\
770 Beware that parentheses need to be escaped (e.g., by backslashes) for shells.\n\
771 INTEGER may also be -l STRING, which evaluates to the length of STRING.\n\
772 "), stdout);
773 fputs (_("\
775 NOTE: Binary -a and -o are inherently ambiguous. Use 'test EXPR1 && test\n\
776 EXPR2' or 'test EXPR1 || test EXPR2' instead.\n\
777 "), stdout);
778 fputs (_("\
780 NOTE: [ honors the --help and --version options, but test does not.\n\
781 test treats each of those as it treats any other nonempty STRING.\n\
782 "), stdout);
783 printf (USAGE_BUILTIN_WARNING, _("test and/or ["));
784 emit_ancillary_info (PROGRAM_NAME);
786 exit (status);
788 #endif /* TEST_STANDALONE */
790 #if !defined TEST_STANDALONE
791 # define main test_command
792 #endif
794 #define AUTHORS \
795 proper_name ("Kevin Braunsdorf"), \
796 proper_name ("Matthew Bradburn")
799 * [:
800 * '[' expr ']'
801 * test:
802 * test expr
805 main (int margc, char **margv)
807 bool value;
809 #if !defined TEST_STANDALONE
810 int code;
812 code = setjmp (test_exit_buf);
814 if (code)
815 return (test_error_return);
816 #else /* TEST_STANDALONE */
817 initialize_main (&margc, &margv);
818 set_program_name (margv[0]);
819 setlocale (LC_ALL, "");
820 bindtextdomain (PACKAGE, LOCALEDIR);
821 textdomain (PACKAGE);
823 initialize_exit_failure (TEST_FAILURE);
824 atexit (close_stdout);
825 #endif /* TEST_STANDALONE */
827 argv = margv;
829 if (LBRACKET)
831 /* Recognize --help or --version, but only when invoked in the
832 "[" form, when the last argument is not "]". Use direct
833 parsing, rather than parse_long_options, to avoid accepting
834 abbreviations. POSIX allows "[ --help" and "[ --version" to
835 have the usual GNU behavior, but it requires "test --help"
836 and "test --version" to exit silently with status 0. */
837 if (margc == 2)
839 if (STREQ (margv[1], "--help"))
840 usage (EXIT_SUCCESS);
842 if (STREQ (margv[1], "--version"))
844 version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
845 (char *) NULL);
846 test_main_return (EXIT_SUCCESS);
849 if (margc < 2 || !STREQ (margv[margc - 1], "]"))
850 test_syntax_error (_("missing %s"), quote ("]"));
852 --margc;
855 argc = margc;
856 pos = 1;
858 if (pos >= argc)
859 test_main_return (TEST_FALSE);
861 value = posixtest (argc - 1);
863 if (pos != argc)
864 test_syntax_error (_("extra argument %s"), quote (argv[pos]));
866 test_main_return (value ? TEST_TRUE : TEST_FALSE);