History log of /freebsd-10.0-release/bin/test/test.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 251208 31-May-2013 jilles

test: Remove -ntXY and -otXY primaries.

This reverts commit r247274.

As maintainer of sh, I disapprove of this feature addition.

It is too specific and can be done without easily using find(1) or stat(1).
I will add some hints to the test(1) man page shortly.

In general, FreeBSD sh is not the place to invent new shell language
features. This is how it has been maintained and adding features randomly
does not work with that.

The new syntax (e.g. [ FILE1 -ntca FILE2 ]) looks cryptic to me.


# 247274 25-Feb-2013 peterj

Enhance test(1) by adding provision to compare any combination of the
access, birth, change and modify times of two files, instead of only
being able to compare modify times. The builtin test in sh(1) will
automagically acquire the same expansion.

Approved by: grog
MFC after: 2 weeks


# 227984 25-Nov-2011 jilles

test: Reduce code size of ops table.


# 226961 31-Oct-2011 ed

Put some static keywords in the source code.

For these simple utilities, it doesn't harm to make all global variables
static. In fact, this allows the compiler to perform better forms of
optimisation and analysis.


# 219680 15-Mar-2011 jilles

bin: Prefer strrchr() to rindex().

This removes the last index/rindex usage from /bin.


# 219084 27-Feb-2011 delphij

Accept == as an alias of = which is a popular GNU extension.

This is intentionally undocumented for now since it's not part
of any standard.

MFC after: 1 month


# 218724 15-Feb-2011 jilles

test: Note that this is used both as a normal program and a shell builtin.

MFC after: 1 week


# 205793 28-Mar-2010 ed

Change all our own code to use st_*tim instead of st_*timespec.

Also remove some local patches to diff(1) which are now unneeded.


# 192862 26-May-2009 jilles

Fix various cases with 3 or 4 parameters in test(1) to be POSIX compliant.
More precisely, this gives precedence to an interpretation not using the
'(', ')', '-a' and '-o' in their special meaning, if possible. For example,
it is now safe to write [ "$a" = "$b" ] and assume it compares the two
strings.

The man page already says that test(1) works this way, so does not need to
be changed.

Interpretation of input with more parameters tries a bit harder to find a
valid parse in some cases.

Add various additional test cases to TEST.sh.

PR: standards/133369
Approved by: ed (mentor)


# 139969 10-Jan-2005 imp

/*- or .\"- or #- to begin license clauses.


# 102097 19-Aug-2002 maxim

Forced commit to correct a PR number in the previous commit. It is bin/40177.

Pointed out by: obrien


# 101923 15-Aug-2002 maxim

o Backout rev. 1.40 and rev. 1.49.
o Add argv[] boudary check.

PR: bin/40117
Reviewed by: silence on -audit
MFC after: 2 months


# 100774 27-Jul-2002 dwmalone

Make test check the tv_nsec part of a struct stat when comparing
the mtimes of a file. (This is probably only useful if you have
vfs.timestamp_precision set to something nonzero).

PR: 39163
Submitted by: Hal Burch <hburch@lumeta.com>
MFC after: 2 weeks


# 99436 05-Jul-2002 maxim

Fix a memory leak.

PR: bin/40177
MFC after: 1 week


# 99110 30-Jun-2002 obrien

Consistently use FBSDID


# 96376 10-May-2002 alfred

while i'm breaking stuff, use __dead2 instead of GCC specific __attribute__.


# 96375 10-May-2002 alfred

backout additional include of cdefs.h, it's not helping any.


# 96374 10-May-2002 alfred

include cdefs.h for __printf0like to silence warning.


# 93345 28-Mar-2002 ache

Use intmax_t as quad_t replacement, like in expr


# 91737 06-Mar-2002 maxim

Log:
Remove eaccess(2) absence workaround. Add eaccess(2) checks for FILRD,
FILWR, FILEX and FILEXIST cases.

We cannot MFC this because there is no eaccess(2) in -stable yet.

PR: bin/35076
Reviewed by: ru
Approved by: ru


# 90157 03-Feb-2002 kris

__printflike() should really be __printf0like() since verrx() can
accept a NULL format string.


# 90156 03-Feb-2002 kris

Add a __printflike() attribute to silence warning with FORMAT_AUDIT=1


# 90133 03-Feb-2002 knu

Work around a buffer overflow problem on argv that has been exposed
after making test(1) a sh(1) builtin; sh(1) coredumps when you run
something like this:

sh -c 'test ! `true 1`'

The cause is that the test(1) code totally depends on the presence of
two extra cells at the end of argv that are filled with NULL's. The
reason why the bug hasn't been exposed would be because the C startup
code kindly prepares argv with some extra zeroed cells for a program.

I know this is not the best fix, but since there are argv++'s without
boundary checks everywhere, I'd rather patch it up like this
(preparing a copy of argv with extra NULL's) for the moment.

MFC after: 3 days


# 90111 02-Feb-2002 imp

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.
o Change
int
foo() {
...
to
int
foo(void)
{
...


# 88471 25-Dec-2001 ache

strtoq -> strtoll (strtoq is deprecated)


# 88084 17-Dec-2001 ache

1) Localize (LC_CTYPE)
2) Catch "" to 0 conversion for OSes that not catch it in strto*()
(f.e. -stable). It is needed because POSIX agrees with both variants.


# 87961 14-Dec-2001 ache

POSIX strto*() functions MAY return EINVAL, so don't assume that only one
errno from them allowed and it is always ERANGE


# 86622 19-Nov-2001 knu

Fix style bugs I found, and add a comment.


# 86619 19-Nov-2001 knu

Oops sorry, forgot to add a #include.


# 86618 19-Nov-2001 knu

- Do not reference argv[1] if no argument is given.

Reported by: brian

- Call error() instead of errx() if compiled as sh(1) builtin.


# 86505 17-Nov-2001 knu

Make test(1) a builtin command of our sh(1) for efficiency. The
binary size increase is 3,784 bytes (about 0.6%).

I don't drop the printf builtin while I'm here because some /etc/rc.*
scripts seem to use it before mounting /usr where printf(1) resides.

Reviewed by: arch (sheldonh)
Inspired by: NetBSD, ksh
Clued by: ume (on how the printf builtin is used)


# 76883 20-May-2001 kris

Silence WARNS=2 and BDECFLAGS on alpha and i386

MFC After: 1 week


# 62925 10-Jul-2000 se

Add support for 64bit integer comparisons.


# 55179 28-Dec-1999 sheldonh

Take into account the fact that "[" may be called with a path,
for example "/bin/[".

Reported by: Vlad Skvortsov <vss@ulstu.ru>
Reported by: Peter Jeremy <peter.jeremy@alcatel.com.au>
Message-Id: 99Dec27.111307est.40321@border.alcanet.com.au


# 50471 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 50302 24-Aug-1999 green

Make the comments nice, short-but-sweet XXX format.

Submitted by: sheldonh


# 50189 22-Aug-1999 green

Make a comment I added a bit nicer.


# 50087 20-Aug-1999 green

Finally: fix test -x as completely as possible.

Reviewed by: bde
Reworked by: bde


# 49993 17-Aug-1999 green

The new test(1) did not use access() correctly. I don't know why, since
supposedly it's ksh-derived, and it's not broken in pdksh. I've added
a test for test running as root: if testing for -x, the file must be
mode & 0111 to get "success", rather than just existant.

Reviewed by: chris


# 49884 16-Aug-1999 sheldonh

Replace our test(1) with NetBSD's pdksh-derived version. The code is
significantly easier to read and extend and offers a few new tests.
A few style changes taken from style(9) and OpenBSD, as well as
whitespace cleanups.

This change was discussed on freebsd-committers and freebsd-hackers
and met with approval from at least des, eivind and brian.

PR: 13091
Obtained from: NetBSD


# 49707 14-Aug-1999 chris

Minor style fix - change 'if(!*v)' to 'if (!*v)'


# 46684 08-May-1999 kris

Various spelling/formatting changes.

Submitted by: Philippe Charnier <charnier@xp11.frmug.org>


# 38914 07-Sep-1998 cracauer

Add -S flag to test for sockets.
PR: bin/7507
Reviewed by: I tested the patch
Submitted by: Stefan `Sec` Zehl sec@42.org


# 36152 18-May-1998 charnier

Correct use of .Nm. Add rcsid.


# 31666 10-Dec-1997 eivind

Remove simultaneous include of <sys/param.h> and <sys/types.h>.
Reorder includes to be alphabetical some places since I already was in
here.


# 22988 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 20903 24-Dec-1996 steve

Fix handling of -o and -a operators in the 3 argument case.

Submitted by: Tom Rush <tarush@mindspring.com>


# 20424 14-Dec-1996 steve

-Wall cleaning.


# 14539 11-Mar-1996 joerg

err() --> errx() for non-errno related failures.


# 11855 28-Oct-1995 ache

Fix -h option:
sense symlink even it is unresolved


# 8855 29-May-1995 rgrimes

Remove trailing whitespace.

Reviewed by: phk


# 7165 19-Mar-1995 joerg

You will find enclosed some changes to make gcc -Wall more happy in
/usr/src/bin. Note that some patches are still needed in that directory.

I (Joerg) finished most of Philippe's cleanup. /bin/sh will still
need *allot* of work, however.

Submitted by: charnier@lirmm.fr (Philippe Charnier)


# 4171 05-Nov-1994 ache

Fix group permissions check for group list size > 1
Pointed by Bruce


# 4170 05-Nov-1994 ache

Fix root -w case according to manpage (-x & -r cases already accords)
Pointed by Bruce.


# 4168 05-Nov-1994 ache

Cosmetique, missing tab/spaces after patch


# 4167 05-Nov-1994 ache

More complex implementation of previos superuser fix
because rw and x bit treats differently infact


# 4166 05-Nov-1994 ache

test produce wrong results for superuser, i.e. tells
that file is unreadable when it is readable infact.


# 3044 24-Sep-1994 dg

Added $Id$


# 2675 11-Sep-1994 csgr

Make get_int() think that "" (null) has the integer value 0.
(Which is the same behaviour as in 1.x)
The install blows up without this.
Reviewed by: rgrimes


# 2664 11-Sep-1994 csgr

- handle signs on integers properly,
- make sure error messages for bad integers are moderately sensible
- handle test ! "abc" -o "abc" (This should evaluate to true)
(and similar cases) ie:
and/or operator test added to POSIX special case processing.
- more test cases added.

Based on: Work done on 1.x's test(1) by Andrew Moore and Adam David.


# 1557 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1556,
which included commits to RCS files with non-trunk default branches.


# 1556 26-May-1994 rgrimes

BSD 4.4 Lite bin Sources