Home | History | Annotate | Download | only in test
History log of /src/bin/test/test.c
RevisionDateAuthorComments
 1.45  27-Aug-2022  dholland PR 56983 Izumi Tsutsui: fix confusing message in test(1) with -DSMALL
 1.44  05-Dec-2021  msaitoh s/existance/existence/ in comment.
 1.43  13-Sep-2018  kre branches: 1.43.2;

Allow SMALL (and TINY) builds of test (for SMALL/TINY builds of sh)
which support only the defined modes of operation of test, to allow
the version of sh on small install media be kept as small as possible.
 1.42  12-Sep-2018  kre PR standards/34646

Make test(1) always use the POSIX "number of args" evaluation rules
when they apply.

Only fall back to the old expression evaluation when there are more
than 4 args, or when the args given cannot work as a test expression
using the POSIX rules. That is when the result is unspecified.

Also fix old bug where a string of whitespace is considered to be a
valid number (at least one digit is needed amongst it somewhere...)

XXX pullup -8
 1.41  05-Sep-2016  sevan branches: 1.41.12; 1.41.14;
Drop main() prototype.
 1.40  04-May-2013  uebayasi test(1): Compare timestamp in nsec scale in -nt/-ot.
 1.39  15-Mar-2012  joerg branches: 1.39.2;
Add __printflike attribution to use vprintf and friends with an argument
as format string.
 1.38  29-Aug-2011  joerg branches: 1.38.2;
Use __dead
 1.37  10-Sep-2008  christos bin/39446: Aleksey Cheusov: always produce errors on empty numbers.
 1.36  20-Jun-2008  christos make getn return long long to support large numbers on all archs.
 1.35  26-May-2008  christos PR/38755: murray armfield: /bin posix programs missing setprogname and/or
setlocale
 1.34  15-Dec-2007  perry branches: 1.34.4; 1.34.6;
convert __attribute__s to applicable cdefs.h macros
 1.33  24-Jun-2007  christos branches: 1.33.4;
PR/36534: Greg A. Woods: test(1) doesn't do -r and -w quite right
Use stat(2) instead of access(2) per POSIX.
 1.32  24-May-2007  christos Make sure we don't run over the end of the argument array while scanning
for input. This can happen if we have a unary not without an argument. When
we scan for the argument, we are already at the NULL element of the argument
array. Then when we scan ahead for a -a or -o, we end up testing the next
element after the NULL.
 1.31  28-Mar-2007  christos PR/36092: B K: algorithmic inefficiency in bin/test/test.c:t_lex
test(1) scans for "operators" linearly in an array using strcmp() to
find a match. Since the list of "operators" is fixed, split them
into one and two character ones, and ones that start with a `-' and
ones they don't. This way we can optimize the compare function to
just check for one or two characters. Sort and use bsearch(3). We
could have used a single sorted array and bsearch(3), to save some
complexity, but I decided to be a bit fancier.
 1.30  24-Sep-2006  hubertf Revert previous (==) - not worth the trouble.
 1.29  22-Sep-2006  hubertf Allow '==' as synonym to '=', just like our ksh and bash do.
This also affects the sh(1) builtin test command.
 1.28  04-Aug-2006  christos don't call get/set progname when we are a shell built-in.
 1.27  04-Aug-2006  christos use getprogname() instead of argv[0], because some programs that execv, pass
the full path in argv[0] instead of just the basename. In reality, those
programs should be fixed (hello gdb for example).
 1.26  10-Feb-2005  simonb KNF, use NULL instead of (type *)0.
 1.25  25-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.24  16-Sep-2001  wiz Some KNF fixes by Petri Koistinen and me.
 1.23  30-Jul-2001  wiz ANSIfy and slight KNF. Mostly #13594 by Petri Koistinen.
 1.22  09-Apr-2000  christos - Enable test to be a shell builtin
- KNF
- Fix bug where test without arguments could access invalid memory
 1.21  05-Apr-1999  kleink Operator precedence consistency; from "Andrew_L. Moore" <alm@SlewSys.Org>
in PR bin/7015.
 1.20  04-Nov-1998  christos branches: 1.20.2;
char -> unsigned char
 1.19  28-Jul-1998  mycroft Be more retentive about use of NOTREACHED and noreturn.
 1.18  19-Oct-1997  mycroft Use S_IS*(), not S_IF*.
 1.17  20-Jul-1997  christos Fix compiler warnings.
Add WARNS=1
 1.16  09-Jan-1997  tls kill use of register
 1.15  21-Mar-1995  cgd clean up Id's, and such. reorganize man page slight to match lite's org.
 1.14  07-Jul-1994  cgd from jtc: insure that 3 and 4 argument special cases work properly.
 1.13  30-Jun-1994  jtc branches: 1.13.2;
Replaced test with simpler, more feature rich, version derived from pdksh.
 1.12  29-Jun-1994  jtc Removed code that checked if arg was a unary operator when test is called
with only one argument. It's not a syntax error --- it's a special case.
 1.11  10-Apr-1994  cgd fix syntax error when only have one arg. from Jarle Greipsland
 1.10  19-Feb-1994  cgd add support for 'test -h' a la SunOS
 1.9  26-Oct-1993  cgd fix from Andrew Moore <alm@netcom.com> to fix test's handling of
(non-negated) "-a" and "-o".
 1.8  23-Sep-1993  mycroft From alm:

Added and/or operator test to POSIX special case processing, so now:
$ test ! "abc" -o "abc"
evaluates to true.

The correct fix is probably to yank the superfluous special case code, but
I don't have time to verify the correctness of the result.
 1.7  23-Sep-1993  mycroft Put back RCS identifier.
 1.6  15-Sep-1993  alm test "0 " -eq 0 now evaluates to true.
It also does range checking. These override J.T.'s patches.
 1.5  08-Sep-1993  jtc Ignore leading whitespace and handle `-' and `+' for operands of integer
comparisions.
 1.4  08-Sep-1993  alm /bin/test " 5" -eq 5 now evaluates to true, rather than return an error.
/bin/test "5 a" -eq 5 still correclty returns an error.
 1.3  01-Aug-1993  mycroft Add RCS identifiers.
 1.2  15-Jun-1993  cgd get the [ ! "" ] case right.
 1.1  26-Apr-1993  glass new 'test' from ftp.uu.net:/systems/unix/bsd-sources, got rid of GNU thing
 1.13.2.1  07-Jul-1994  cgd from jtc: insure that 3 and 4 argument special cases work properly.
 1.20.2.2  03-Jun-2000  he Pull up revision 1.22 (requested by he):
Enable test as a shell builtin. Fixes PR#9847.
 1.20.2.1  03-Jun-2000  he Pull up revision 1.21 (requested by he):
Fix operator precedence consistency. Fixes PR#7015.
 1.33.4.1  09-Jan-2008  matt sync with HEAD
 1.34.6.2  24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.34.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.34.4.1  04-Jun-2008  yamt sync with head
 1.38.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.38.2.1  17-Apr-2012  yamt sync with head
 1.39.2.1  23-Jun-2013  tls resync from head
 1.41.14.3  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.41.14.2  21-Apr-2020  martin Sync with HEAD
 1.41.14.1  10-Jun-2019  christos Sync with HEAD
 1.41.12.1  30-Sep-2018  pgoyette Ssync with HEAD
 1.43.2.1  29-Aug-2022  martin Pull up following revision(s) (requested by dholland in ticket #1507):

bin/test/test.c: revision 1.45

PR 56983 Izumi Tsutsui: fix confusing message in test(1) with -DSMALL

RSS XML Feed