mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
Add support for a "[" that conforms to the GNU coding standards,
i.e., that does not depend on its name. (LBRACKET): Define to 0 if not defined. (main): Use LBRACKET rather than argv[0]. ---------- (one_argument): Do not check for -t if POSIXLY_CORRECT. (main): Do not recognize --help or --version if POSIXLY_CORRECT, when invoked as "test". Handle "[ ]" correctly. Do not bother testing that margv[margc] is non-null.
This commit is contained in:
1 parent
138fd919b8
commit
05731b4717
1 file changed
+12
-14
+12
-14
@@ -32,6 +32,10 @@
|
||||
|
||||
#define TEST_STANDALONE 1
|
||||
|
||||
#ifndef LBRACKET
|
||||
# define LBRACKET 0
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "euidaccess.h"
|
||||
@@ -859,7 +863,7 @@ unop (int op)
|
||||
static int
|
||||
one_argument (const char *s)
|
||||
{
|
||||
if (STREQ (s, "-t"))
|
||||
if (! getenv ("POSIXLY_CORRECT") && STREQ (s, "-t"))
|
||||
return (TRUE == (isatty (1)));
|
||||
|
||||
return strlen (s) != 0;
|
||||
@@ -1082,32 +1086,26 @@ main (int margc, char **margv)
|
||||
atexit (close_stdout);
|
||||
#endif /* TEST_STANDALONE */
|
||||
|
||||
argv = margv;
|
||||
/* Recognize --help or --version unless POSIXLY_CORRECT is set. */
|
||||
if (! getenv ("POSIXLY_CORRECT"))
|
||||
parse_long_options (margc, margv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
if (margv[0] && strcmp (margv[0], "[") == 0)
|
||||
if (LBRACKET)
|
||||
{
|
||||
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
|
||||
if (getenv ("POSIXLY_CORRECT") == NULL)
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
|
||||
--margc;
|
||||
|
||||
if (margc < 2)
|
||||
test_exit (SHELL_BOOLEAN (FALSE));
|
||||
|
||||
if (margv[margc] && strcmp (margv[margc], "]") != 0)
|
||||
if (margc < 1 || strcmp (margv[margc], "]") != 0)
|
||||
test_syntax_error (_("missing `]'\n"), NULL);
|
||||
}
|
||||
|
||||
argv = margv;
|
||||
argc = margc;
|
||||
pos = 1;
|
||||
|
||||
if (pos >= argc)
|
||||
test_exit (SHELL_BOOLEAN (FALSE));
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
|
||||
AUTHORS, usage);
|
||||
value = posixtest ();
|
||||
|
||||
if (pos != argc)
|
||||
|
||||
Reference in new issue
Block a user