Home | History | Annotate | only in /src/bin/test
History log of /src/bin/test
RevisionDateAuthorComments
 1.11 22-Jun-2007  simonb branches: 1.11.78;
Remove a "CFLAGS+=-g" that seems to have snuck in with no good reason.
 1.10 11-Sep-2006  dbj fixes for installing into a case insensitive $DESTDIR
when files may have hard links to a a name that only differs by case
- change install to unconditionally remove its temporary file
when installing hard links with -r. This avoids problems when
built with posix rename(2) semantics and reinstalling an existing
hard link.
- rework hard link targets in bsd.man.mk and bsd.links.mk
to use makefile constructs instead of shell constructs
- always reinstall hard links that may have case conflicts, even
when MKUPDATE=yes, this ensures that they get added to METALOG
- remove man pages which were hard linked to themselves in libform
- remove improper hard link command for existing man page in libkrb5
- fix libl's makefile to include bsd.lib.mk at end
- remove shell quoting in link target for test's [.1 man page
 1.9 04-Aug-2006  christos don't call get/set progname when we are a shell built-in.
 1.8 20-Jul-1997  christos Remove WARNS=1 from all the subdirectory Makefiles, and add it to Makefile.inc
now that all /bin has been cleaned.
 1.7 20-Jul-1997  christos Fix compiler warnings.
Add WARNS=1
 1.6 21-Mar-1995  cgd clean up Id's, and such. reorganize man page slight to match lite's org.
 1.5 30-Jun-1994  jtc Replaced test with simpler, more feature rich, version derived from pdksh.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 29-Apr-1993  glass ugh. i was right after all.
 1.2 27-Apr-1993  glass bostic was right, and i was wrong.. boo.
 1.1 26-Apr-1993  glass new 'test' from ftp.uu.net:/systems/unix/bsd-sources, got rid of GNU thing
 1.11.78.2 21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.11.78.1 21-Apr-2020  martin Sync with HEAD
 1.2 21-Mar-1995  cgd branches: 1.2.116;
clean up Id's, and such. reorganize man page slight to match lite's org.
 1.1 26-Apr-1993  glass new 'test' from ftp.uu.net:/systems/unix/bsd-sources, got rid of GNU thing
 1.2.116.2 21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.2.116.1 21-Apr-2020  martin Sync with HEAD
 1.2 30-Jun-1994  mycroft Clean up deleted files.
 1.1 26-Apr-1993  glass new 'test' from ftp.uu.net:/systems/unix/bsd-sources, got rid of GNU thing
 1.3 30-Jun-1994  mycroft Clean up deleted files.
 1.2 19-Feb-1994  cgd whack mkops so it 'understands' and/or ops
 1.1 26-Apr-1993  glass new 'test' from ftp.uu.net:/systems/unix/bsd-sources, got rid of GNU thing
 1.6 30-Jun-1994  mycroft Clean up deleted files.
 1.5 19-Feb-1994  cgd add support for 'test -h' a la SunOS
 1.4 19-Feb-1994  cgd whack mkops so it 'understands' and/or ops
 1.3 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.2 02-Aug-1993  mycroft Add RCS identifiers, remove some completely useless RCS logs and patchkit
headers, and a few other insignificant changes.
 1.1 29-Apr-1993  glass ugh. i was right after all.
 1.6 30-Jun-1994  mycroft Clean up deleted files.
 1.5 19-Feb-1994  cgd add support for 'test -h' a la SunOS
 1.4 19-Feb-1994  cgd whack mkops so it 'understands' and/or ops
 1.3 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.2 02-Aug-1993  mycroft operators.c
 1.1 29-Apr-1993  glass ugh. i was right after all.
 1.33 18-Oct-2017  wiz branches: 1.33.4;
Remove unnecessary Tn.
 1.32 18-Oct-2017  kre I have seen (way too often) uses of test(1) that are not defined to
actually work (but just happen to, today, and in some cases, even
that trusts to some luck.)

It has been recently pointed out to me that the man page (ie: this
file) doesn't give any real guidance to what is really acceptable,
and what is not.

The CAVEATS section does note that the grammar is ambiguous, but then
just says that test(1) implements what POSIX requires, and refers
readers to the relevant section of the POSIX standard for more details.
That is probably asking too much of the average reader...

So, add some extra information in the CAVEATS with what is defined to work,
and what should be avoided. Not all of the POSIX rules are here, but this
might hopefully help script authors avoid some of the pitfalls.
 1.31 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.30 12-Aug-2016  sevan Document the version test first appeared.
Bump date.
 1.29 27-May-2016  dholland usage nit
 1.28 16-Dec-2012  wiz - Remove unneeded consecutive argument in `.Nm' macros;
- rename `GRAMMAR AMBIGUITY' section to `CAVEATS', and move it to
correct location;
- bump date.

From Bug Hunting.
 1.27 10-Nov-2009  wiz branches: 1.27.6; 1.27.12;
Correct usage for parentheses, and mark up "expression" in more places.

From Bug Hunting in PR 42286.
 1.26 06-May-2009  wiz Remove leading zero in Dd argument.
 1.25 05-May-2009  jschauma Note that all file tests with the exception of -h and -L follow symbolic
links and thus evaluate the test for the file pointed at.
 1.24 12-Apr-2009  joerg Fix markup.
 1.23 15-May-2007  uwe branches: 1.23.20;
Use the same wording for '-p' as for other file related tests.
 1.22 24-Sep-2006  hubertf Revert previous (==) - not worth the trouble.
 1.21 23-Sep-2006  wiz Bump date for previous.
 1.20 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.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.
 1.18 25-Sep-2002  wiz New policy: New sentences start on a new line.
Patches by Robert Elz <kre at munnari oz au>, with minimal changes by me.
 1.17 08-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.16 20-Dec-2001  wiz Whitespace nits.
 1.15 17-Oct-2001  wiz Properly quote `[' as macro argument.
 1.14 04-Sep-2000  kleink For commands and utilities, use EXIT STATUS rather than RETURN VALUES as
appropriate (and documented in mdoc(7)).
 1.13 17-Dec-1999  abs Remove duplicate 'string' / 's1' entry
 1.12 22-Aug-1999  kleink branches: 1.12.4;
Reverse the advice given to (now) prefer -h over -L; the former is defined in
1003.2bD3 and SVID4 and thus supposedly more portable.
 1.11 09-Mar-1999  garbled branches: 1.11.2;
the '[' wasn't being displayed properly as a command. Thanks to Charles
for the fix.
 1.10 12-Nov-1997  mrg add missing .Nm calls and MLINKS. from spz@serpens.swb.de
 1.9 09-Oct-1997  mycroft branches: 1.9.2;
Fix format of description line.
 1.8 05-Jun-1997  mikel add SYNOPSIS line for [; fixes PR bin/3705
 1.7 05-Jan-1996  pk Note compatibility `-h' op. (from Rob Windsor; PR#1740)
 1.6 21-Mar-1995  cgd clean up Id's, and such. reorganize man page slight to match lite's org.
 1.5 30-Jun-1994  jtc Replaced test with simpler, more feature rich, version derived from pdksh.
 1.4 29-Jun-1994  jtc The file_descriptor argument to the -t primary is no longer optional.
 1.3 19-Feb-1994  cgd add support for 'test -h' a la SunOS
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 26-Apr-1993  glass new 'test' from ftp.uu.net:/systems/unix/bsd-sources, got rid of GNU thing
 1.9.2.1 12-Nov-1997  mrg pull up from trunk: add missing .Nm calls and MLINKS. from spz@serpens.swb.de
 1.11.2.1 17-Dec-1999  he Pull up revision 1.10 (requested by abs):
Remove obsolete reference to mkpasswd(8).
 1.12.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.23.20.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.27.12.1 25-Feb-2013  tls resync with head
 1.27.6.1 23-Jan-2013  yamt sync with head
 1.33.4.2 21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.33.4.1 21-Apr-2020  martin Sync with HEAD
 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
 1.3 30-Jun-1994  mycroft Clean up deleted files.
 1.2 19-Feb-1994  cgd add support for 'test -h' a la SunOS
 1.1 26-Apr-1993  glass new 'test' from ftp.uu.net:/systems/unix/bsd-sources, got rid of GNU thing

RSS XML Feed