head 1.33; access; symbols netbsd-10-0-RELEASE:1.33 netbsd-10-0-RC6:1.33 netbsd-10-0-RC5:1.33 netbsd-10-0-RC4:1.33 netbsd-10-0-RC3:1.33 netbsd-10-0-RC2:1.33 netbsd-10-0-RC1:1.33 netbsd-10:1.33.0.14 netbsd-10-base:1.33 netbsd-9-3-RELEASE:1.33 cjep_sun2x-base1:1.33 cjep_sun2x:1.33.0.12 cjep_sun2x-base:1.33 cjep_staticlib_x-base1:1.33 netbsd-9-2-RELEASE:1.33 cjep_staticlib_x:1.33.0.10 cjep_staticlib_x-base:1.33 netbsd-9-1-RELEASE:1.33 phil-wifi-20200421:1.33 phil-wifi-20200411:1.33 is-mlppp:1.33.0.8 is-mlppp-base:1.33 phil-wifi-20200406:1.33 netbsd-8-2-RELEASE:1.30 netbsd-9-0-RELEASE:1.33 netbsd-9-0-RC2:1.33 netbsd-9-0-RC1:1.33 phil-wifi-20191119:1.33 netbsd-9:1.33.0.6 netbsd-9-base:1.33 phil-wifi-20190609:1.33 netbsd-8-1-RELEASE:1.30 netbsd-8-1-RC1:1.30 pgoyette-compat-merge-20190127:1.33 pgoyette-compat-20190127:1.33 pgoyette-compat-20190118:1.33 pgoyette-compat-1226:1.33 pgoyette-compat-1126:1.33 pgoyette-compat-1020:1.33 pgoyette-compat-0930:1.33 pgoyette-compat-0906:1.33 netbsd-7-2-RELEASE:1.28 pgoyette-compat-0728:1.33 netbsd-8-0-RELEASE:1.30 phil-wifi:1.33.0.4 phil-wifi-base:1.33 pgoyette-compat-0625:1.33 netbsd-8-0-RC2:1.30 pgoyette-compat-0521:1.33 pgoyette-compat-0502:1.33 pgoyette-compat-0422:1.33 netbsd-8-0-RC1:1.30 pgoyette-compat-0415:1.33 pgoyette-compat-0407:1.33 pgoyette-compat-0330:1.33 pgoyette-compat-0322:1.33 pgoyette-compat-0315:1.33 netbsd-7-1-2-RELEASE:1.28 pgoyette-compat:1.33.0.2 pgoyette-compat-base:1.33 netbsd-7-1-1-RELEASE:1.28 matt-nb8-mediatek:1.30.0.8 matt-nb8-mediatek-base:1.30 perseant-stdc-iso10646:1.31.0.2 perseant-stdc-iso10646-base:1.31 netbsd-8:1.30.0.6 netbsd-8-base:1.30 prg-localcount2-base3:1.30 prg-localcount2-base2:1.30 prg-localcount2-base1:1.30 prg-localcount2:1.30.0.4 prg-localcount2-base:1.30 pgoyette-localcount-20170426:1.30 bouyer-socketcan-base1:1.30 pgoyette-localcount-20170320:1.30 netbsd-7-1:1.28.0.16 netbsd-7-1-RELEASE:1.28 netbsd-7-1-RC2:1.28 netbsd-7-nhusb-base-20170116:1.28 bouyer-socketcan:1.30.0.2 bouyer-socketcan-base:1.30 pgoyette-localcount-20170107:1.30 netbsd-7-1-RC1:1.28 pgoyette-localcount-20161104:1.30 netbsd-7-0-2-RELEASE:1.28 localcount-20160914:1.30 netbsd-7-nhusb:1.28.0.14 netbsd-7-nhusb-base:1.28 pgoyette-localcount-20160806:1.29 pgoyette-localcount-20160726:1.29 pgoyette-localcount:1.29.0.2 pgoyette-localcount-base:1.29 netbsd-7-0-1-RELEASE:1.28 netbsd-7-0:1.28.0.12 netbsd-7-0-RELEASE:1.28 netbsd-7-0-RC3:1.28 netbsd-7-0-RC2:1.28 netbsd-7-0-RC1:1.28 netbsd-5-2-3-RELEASE:1.23 netbsd-5-1-5-RELEASE:1.23 netbsd-6-0-6-RELEASE:1.27 netbsd-6-1-5-RELEASE:1.27 netbsd-7:1.28.0.10 netbsd-7-base:1.28 yamt-pagecache-base9:1.28 yamt-pagecache-tag8:1.27.6.1 netbsd-6-1-4-RELEASE:1.27 netbsd-6-0-5-RELEASE:1.27 tls-earlyentropy:1.28.0.8 tls-earlyentropy-base:1.28 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.28 riastradh-drm2-base3:1.28 netbsd-6-1-3-RELEASE:1.27 netbsd-6-0-4-RELEASE:1.27 netbsd-5-2-2-RELEASE:1.23 netbsd-5-1-4-RELEASE:1.23 netbsd-6-1-2-RELEASE:1.27 netbsd-6-0-3-RELEASE:1.27 netbsd-5-2-1-RELEASE:1.23 netbsd-5-1-3-RELEASE:1.23 netbsd-6-1-1-RELEASE:1.27 riastradh-drm2-base2:1.28 riastradh-drm2-base1:1.28 riastradh-drm2:1.28.0.2 riastradh-drm2-base:1.28 netbsd-6-1:1.27.0.16 netbsd-6-0-2-RELEASE:1.27 netbsd-6-1-RELEASE:1.27 khorben-n900:1.28.0.6 netbsd-6-1-RC4:1.27 netbsd-6-1-RC3:1.27 agc-symver:1.28.0.4 agc-symver-base:1.28 netbsd-6-1-RC2:1.27 netbsd-6-1-RC1:1.27 yamt-pagecache-base8:1.28 netbsd-5-2:1.23.0.30 netbsd-6-0-1-RELEASE:1.27 yamt-pagecache-base7:1.27 netbsd-5-2-RELEASE:1.23 netbsd-5-2-RC1:1.23 matt-nb6-plus-nbase:1.27 yamt-pagecache-base6:1.27 netbsd-6-0:1.27.0.14 netbsd-6-0-RELEASE:1.27 netbsd-6-0-RC2:1.27 tls-maxphys:1.27.0.12 tls-maxphys-base:1.28 matt-nb6-plus:1.27.0.10 matt-nb6-plus-base:1.27 netbsd-6-0-RC1:1.27 yamt-pagecache-base5:1.27 yamt-pagecache-base4:1.27 netbsd-6:1.27.0.8 netbsd-6-base:1.27 netbsd-5-1-2-RELEASE:1.23 netbsd-5-1-1-RELEASE:1.23 yamt-pagecache-base3:1.27 yamt-pagecache-base2:1.27 yamt-pagecache:1.27.0.6 yamt-pagecache-base:1.27 cherry-xenmp:1.27.0.4 cherry-xenmp-base:1.27 bouyer-quota2-nbase:1.27 bouyer-quota2:1.27.0.2 bouyer-quota2-base:1.27 matt-mips64-premerge-20101231:1.27 matt-nb5-mips64-premerge-20101231:1.23 matt-nb5-pq3:1.23.0.28 matt-nb5-pq3-base:1.23 netbsd-5-1:1.23.0.26 netbsd-5-1-RELEASE:1.23 netbsd-5-1-RC4:1.23 matt-nb5-mips64-k15:1.23 netbsd-5-1-RC3:1.23 netbsd-5-1-RC2:1.23 netbsd-5-1-RC1:1.23 netbsd-5-0-2-RELEASE:1.23 matt-nb5-mips64-premerge-20091211:1.23 matt-premerge-20091211:1.27 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.23 matt-nb4-mips64-k7-u2a-k9b:1.23 matt-nb5-mips64-u1-k1-k5:1.23 matt-nb5-mips64:1.23.0.24 netbsd-5-0-1-RELEASE:1.23 jym-xensuspend-nbase:1.26 netbsd-5-0:1.23.0.22 netbsd-5-0-RELEASE:1.23 netbsd-5-0-RC4:1.23 netbsd-5-0-RC3:1.23 netbsd-5-0-RC2:1.23 jym-xensuspend:1.23.0.20 jym-xensuspend-base:1.26 netbsd-5-0-RC1:1.23 netbsd-5:1.23.0.18 netbsd-5-base:1.23 matt-mips64-base2:1.23 matt-mips64:1.23.0.16 mjf-devfs2:1.23.0.14 mjf-devfs2-base:1.23 netbsd-4-0-1-RELEASE:1.22 wrstuden-revivesa-base-3:1.23 wrstuden-revivesa-base-2:1.23 wrstuden-fixsa-newbase:1.22 wrstuden-revivesa-base-1:1.23 yamt-pf42-base4:1.23 yamt-pf42-base3:1.23 hpcarm-cleanup-nbase:1.23 yamt-pf42-baseX:1.23 yamt-pf42-base2:1.23 wrstuden-revivesa:1.23.0.12 wrstuden-revivesa-base:1.23 yamt-pf42:1.23.0.10 yamt-pf42-base:1.23 keiichi-mipv6:1.23.0.8 keiichi-mipv6-base:1.23 matt-armv6-nbase:1.23 matt-armv6-prevmlocking:1.23 wrstuden-fixsa-base-1:1.22 netbsd-4-0:1.22.0.6 netbsd-4-0-RELEASE:1.22 cube-autoconf:1.23.0.6 cube-autoconf-base:1.23 netbsd-4-0-RC5:1.22 netbsd-4-0-RC4:1.22 netbsd-4-0-RC3:1.22 netbsd-4-0-RC2:1.22 netbsd-4-0-RC1:1.22 matt-armv6:1.23.0.4 matt-armv6-base:1.23 matt-mips64-base:1.23 hpcarm-cleanup:1.23.0.2 hpcarm-cleanup-base:1.23 netbsd-3-1-1-RELEASE:1.19 netbsd-3-0-3-RELEASE:1.19 wrstuden-fixsa:1.22.0.4 wrstuden-fixsa-base:1.22 abandoned-netbsd-4-base:1.19 abandoned-netbsd-4:1.19.0.12 netbsd-3-1:1.19.0.14 netbsd-3-1-RELEASE:1.19 netbsd-3-0-2-RELEASE:1.19 netbsd-3-1-RC4:1.19 netbsd-3-1-RC3:1.19 netbsd-3-1-RC2:1.19 netbsd-3-1-RC1:1.19 netbsd-4:1.22.0.2 netbsd-4-base:1.22 netbsd-3-0-1-RELEASE:1.19 netbsd-3-0:1.19.0.10 netbsd-3-0-RELEASE:1.19 netbsd-3-0-RC6:1.19 netbsd-3-0-RC5:1.19 netbsd-3-0-RC4:1.19 netbsd-3-0-RC3:1.19 netbsd-3-0-RC2:1.19 netbsd-3-0-RC1:1.19 netbsd-2-0-3-RELEASE:1.19 netbsd-2-1:1.19.0.8 netbsd-2-1-RELEASE:1.19 netbsd-2-1-RC6:1.19 netbsd-2-1-RC5:1.19 netbsd-2-1-RC4:1.19 netbsd-2-1-RC3:1.19 netbsd-2-1-RC2:1.19 netbsd-2-1-RC1:1.19 netbsd-2-0-2-RELEASE:1.19 netbsd-3:1.19.0.6 netbsd-3-base:1.19 netbsd-2-0-1-RELEASE:1.19 netbsd-2:1.19.0.4 netbsd-2-base:1.19 netbsd-2-0-RELEASE:1.19 netbsd-2-0-RC5:1.19 netbsd-2-0-RC4:1.19 netbsd-2-0-RC3:1.19 netbsd-2-0-RC2:1.19 netbsd-2-0-RC1:1.19 netbsd-2-0:1.19.0.2 netbsd-2-0-base:1.19 netbsd-1-6-PATCH002-RELEASE:1.17 netbsd-1-6-PATCH002:1.17 netbsd-1-6-PATCH002-RC4:1.17 netbsd-1-6-PATCH002-RC3:1.17 netbsd-1-6-PATCH002-RC2:1.17 netbsd-1-6-PATCH002-RC1:1.17 netbsd-1-6-PATCH001:1.17 netbsd-1-6-PATCH001-RELEASE:1.17 netbsd-1-6-PATCH001-RC3:1.17 netbsd-1-6-PATCH001-RC2:1.17 netbsd-1-6-PATCH001-RC1:1.17 fvdl_fs64_base:1.18 netbsd-1-6-RELEASE:1.17 netbsd-1-6-RC3:1.17 netbsd-1-6-RC2:1.17 netbsd-1-6-RC1:1.17 netbsd-1-6:1.17.0.2 netbsd-1-6-base:1.17 netbsd-1-5-PATCH003:1.13 netbsd-1-5-PATCH002:1.13 netbsd-1-5-PATCH001:1.13 netbsd-1-5-RELEASE:1.13 netbsd-1-5-BETA2:1.13 netbsd-1-5-BETA:1.13 netbsd-1-4-PATCH003:1.11.2.1 netbsd-1-5-ALPHA2:1.13 netbsd-1-5:1.13.0.4 netbsd-1-5-base:1.13 minoura-xpg4dl:1.13.0.2 minoura-xpg4dl-base:1.13 netbsd-1-4-PATCH002:1.11.2.1 wrstuden-devbsize-19991221:1.13 wrstuden-devbsize:1.12.0.4 wrstuden-devbsize-base:1.13 comdex-fall-1999:1.12.0.2 comdex-fall-1999-base:1.12 netbsd-1-4-PATCH001:1.11 netbsd-1-4-RELEASE:1.11 netbsd-1-4:1.11.0.2 netbsd-1-4-base:1.11 netbsd-1-3-PATCH003:1.9.2.1 netbsd-1-3-PATCH003-CANDIDATE2:1.9.2.1 netbsd-1-3-PATCH003-CANDIDATE1:1.9.2.1 netbsd-1-3-PATCH003-CANDIDATE0:1.9.2.1 netbsd-1-3-PATCH002:1.9.2.1 netbsd-1-3-PATCH001:1.9.2.1 netbsd-1-3-RELEASE:1.9.2.1 netbsd-1-3-BETA:1.9.2.1 netbsd-1-3:1.9.0.2 netbsd-1-3-base:1.9 netbsd-1-2-PATCH001:1.7 netbsd-1-2-RELEASE:1.7 netbsd-1-2-BETA:1.7 netbsd-1-2-base:1.7 netbsd-1-2:1.7.0.4 netbsd-1-1-PATCH001:1.6 netbsd-1-1-RELEASE:1.6 netbsd-1-1:1.6.0.2 netbsd-1-1-base:1.6 netbsd-1-0-PATCH06:1.5 netbsd-1-0-PATCH05:1.5 netbsd-1-0-PATCH04:1.5 netbsd-1-0-PATCH03:1.5 netbsd-1-0-PATCH02:1.5 netbsd-1-0-PATCH1:1.5 netbsd-1-0-PATCH0:1.5 netbsd-1-0-RELEASE:1.5 netbsd-1-0:1.5.0.2 netbsd-1-0-base:1.5 netbsd-0-9-RELEASE:1.1 netbsd-0-9-BETA:1.1 netbsd-0-9-ALPHA2:1.1 netbsd-0-9-ALPHA:1.1 netbsd-0-9:1.1.0.2 netbsd-0-9-base:1.1; locks; strict; comment @# @; 1.33 date 2017.10.18.18.11.54; author wiz; state Exp; branches 1.33.4.1; next 1.32; commitid YQEAlXfDQQMvUybA; 1.32 date 2017.10.18.08.54.59; author kre; state Exp; branches; next 1.31; commitid Z4RhKviSUBwtPvbA; 1.31 date 2017.07.03.21.33.24; author wiz; state Exp; branches; next 1.30; commitid JUrLsoRkmv9SsPXz; 1.30 date 2016.08.12.03.17.41; author sevan; state Exp; branches; next 1.29; commitid Dg9pCIo2TdkzQXhz; 1.29 date 2016.05.27.05.50.07; author dholland; state Exp; branches; next 1.28; commitid 3fhI0BAKnpxqa58z; 1.28 date 2012.12.16.17.57.49; author wiz; state Exp; branches; next 1.27; 1.27 date 2009.11.10.18.19.46; author wiz; state Exp; branches 1.27.6.1 1.27.12.1; next 1.26; 1.26 date 2009.05.06.08.26.43; author wiz; state Exp; branches; next 1.25; 1.25 date 2009.05.05.19.04.01; author jschauma; state Exp; branches; next 1.24; 1.24 date 2009.04.12.13.52.20; author joerg; state Exp; branches; next 1.23; 1.23 date 2007.05.15.22.00.51; author uwe; state Exp; branches 1.23.20.1; next 1.22; 1.22 date 2006.09.24.13.24.08; author hubertf; state Exp; branches; next 1.21; 1.21 date 2006.09.23.11.22.10; author wiz; state Exp; branches; next 1.20; 1.20 date 2006.09.22.22.15.24; author hubertf; state Exp; branches; next 1.19; 1.19 date 2003.08.07.09.05.43; author agc; state Exp; branches; next 1.18; 1.18 date 2002.09.25.15.18.44; author wiz; state Exp; branches; next 1.17; 1.17 date 2002.02.08.01.22.01; author ross; state Exp; branches; next 1.16; 1.16 date 2001.12.20.19.31.52; author wiz; state Exp; branches; next 1.15; 1.15 date 2001.10.17.21.14.45; author wiz; state Exp; branches; next 1.14; 1.14 date 2000.09.04.07.30.13; author kleink; state Exp; branches; next 1.13; 1.13 date 99.12.17.13.16.44; author abs; state Exp; branches; next 1.12; 1.12 date 99.08.22.14.06.59; author kleink; state Exp; branches 1.12.4.1; next 1.11; 1.11 date 99.03.09.07.05.33; author garbled; state Exp; branches 1.11.2.1; next 1.10; 1.10 date 97.11.12.00.48.21; author mrg; state Exp; branches; next 1.9; 1.9 date 97.10.09.07.37.09; author mycroft; state Exp; branches 1.9.2.1; next 1.8; 1.8 date 97.06.05.06.39.59; author mikel; state Exp; branches; next 1.7; 1.7 date 96.01.05.12.39.30; author pk; state Exp; branches; next 1.6; 1.6 date 95.03.21.07.04.03; author cgd; state Exp; branches; next 1.5; 1.5 date 94.06.30.05.12.34; author jtc; state Exp; branches; next 1.4; 1.4 date 94.06.29.22.26.50; author jtc; state Exp; branches; next 1.3; 1.3 date 94.02.19.06.29.02; author cgd; state Exp; branches; next 1.2; 1.2 date 93.08.01.07.47.45; author mycroft; state Exp; branches; next 1.1; 1.1 date 93.04.26.23.30.50; author glass; state Exp; branches; next ; 1.33.4.1 date 2020.04.21.18.41.08; author martin; state dead; branches; next 1.33.4.2; commitid 86tA4aEmdr3VCh5C; 1.33.4.2 date 2020.04.21.19.37.35; author martin; state Exp; branches; next ; commitid x6IB64bYH9UmWh5C; 1.27.6.1 date 2013.01.23.00.04.05; author yamt; state Exp; branches; next ; 1.27.12.1 date 2013.02.25.00.23.53; author tls; state Exp; branches; next ; 1.23.20.1 date 2009.05.13.19.15.51; author jym; state Exp; branches; next ; 1.12.4.1 date 99.12.27.18.27.13; author wrstuden; state Exp; branches; next ; 1.11.2.1 date 99.12.17.23.12.47; author he; state Exp; branches; next ; 1.9.2.1 date 97.11.12.01.01.18; author mrg; state Exp; branches; next ; desc @@ 1.33 log @Remove unnecessary Tn. @ text @.\" $NetBSD: test.1,v 1.32 2017/10/18 08:54:59 kre Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" the Institute of Electrical and Electronics Engineers, Inc. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @@(#)test.1 8.1 (Berkeley) 5/31/93 .\" .Dd October 17, 2017 .Dt TEST 1 .Os .Sh NAME .Nm test , .Nm \&[ .Nd condition evaluation utility .Sh SYNOPSIS .Nm .Ar expression .Nm \&[ .Ar expression Cm \&] .Sh DESCRIPTION The .Nm utility evaluates .Ar expression and, if it evaluates to true, returns a zero (true) exit status; otherwise it returns 1 (false). If .Ar expression is not given, .Nm also returns 1 (false). .Pp All operators and flags are separate arguments to the .Nm utility. .Pp The following primaries are used to construct .Ar expression : .Bl -tag -width Ar .It Fl b Ar file True if .Ar file exists and is a block special file. .It Fl c Ar file True if .Ar file exists and is a character special file. .It Fl d Ar file True if .Ar file exists and is a directory. .It Fl e Ar file True if .Ar file exists (regardless of type). .It Fl f Ar file True if .Ar file exists and is a regular file. .It Fl g Ar file True if .Ar file exists and its set group ID flag is set. .It Fl h Ar file True if .Ar file exists and is a symbolic link. .It Fl k Ar file True if .Ar file exists and its sticky bit is set. .It Fl n Ar string True if the length of .Ar string is nonzero. .It Fl p Ar file True if .Ar file exists and is a named pipe (FIFO). .It Fl r Ar file True if .Ar file exists and is readable. .It Fl s Ar file True if .Ar file exists and has a size greater than zero. .It Fl t Ar file_descriptor True if the file whose file descriptor number is .Ar file_descriptor is open and is associated with a terminal. .It Fl u Ar file True if .Ar file exists and its set user ID flag is set. .It Fl w Ar file True if .Ar file exists and is writable. True indicates only that the write flag is on. The file is not writable on a read-only file system even if this test indicates true. .It Fl x Ar file True if .Ar file exists and is executable. True indicates only that the execute flag is on. If .Ar file is a directory, true indicates that .Ar file can be searched. .It Fl z Ar string True if the length of .Ar string is zero. .It Fl L Ar file True if .Ar file exists and is a symbolic link. This operator is retained for compatibility with previous versions of this program. Do not rely on its existence; use .Fl h instead. .It Fl O Ar file True if .Ar file exists and its owner matches the effective user id of this process. .It Fl G Ar file True if .Ar file exists and its group matches the effective group id of this process. .It Fl S Ar file True if .Ar file exists and is a socket. .It Ar file1 Fl nt Ar file2 True if .Ar file1 exists and is newer than .Ar file2 . .It Ar file1 Fl ot Ar file2 True if .Ar file1 exists and is older than .Ar file2 . .It Ar file1 Fl ef Ar file2 True if .Ar file1 and .Ar file2 exist and refer to the same file. .It Ar string True if .Ar string is not the null string. .It Ar \&s\&1 Cm \&= Ar \&s\&2 True if the strings .Ar \&s\&1 and .Ar \&s\&2 are identical. .It Ar \&s\&1 Cm \&!= Ar \&s\&2 True if the strings .Ar \&s\&1 and .Ar \&s\&2 are not identical. .It Ar \&s\&1 Cm \&< Ar \&s\&2 True if string .Ar \&s\&1 comes before .Ar \&s\&2 based on the ASCII value of their characters. .It Ar \&s\&1 Cm \&> Ar \&s\&2 True if string .Ar \&s\&1 comes after .Ar \&s\&2 based on the ASCII value of their characters. .It Ar \&n\&1 Fl \&eq Ar \&n\&2 True if the integers .Ar \&n\&1 and .Ar \&n\&2 are algebraically equal. .It Ar \&n\&1 Fl \&ne Ar \&n\&2 True if the integers .Ar \&n\&1 and .Ar \&n\&2 are not algebraically equal. .It Ar \&n\&1 Fl \> Ar \&n\&2 True if the integer .Ar \&n\&1 is algebraically greater than the integer .Ar \&n\&2 . .It Ar \&n\&1 Fl \&ge Ar \&n\&2 True if the integer .Ar \&n\&1 is algebraically greater than or equal to the integer .Ar \&n\&2 . .It Ar \&n\&1 Fl \< Ar \&n\&2 True if the integer .Ar \&n\&1 is algebraically less than the integer .Ar \&n\&2 . .It Ar \&n\&1 Fl \&le Ar \&n\&2 True if the integer .Ar \&n\&1 is algebraically less than or equal to the integer .Ar \&n\&2 . .El .Pp These primaries can be combined with the following operators: .Bl -tag -width Ar .It Cm \&! Ar expression True if .Ar expression is false. .It Ar expression1 Fl a Ar expression2 True if both .Ar expression1 and .Ar expression2 are true. .It Ar expression1 Fl o Ar expression2 True if either .Ar expression1 or .Ar expression2 is true. .It Cm \&( Ar expression Cm \&) True if .Ar expression is true. .El .Pp The .Fl a operator has higher precedence than the .Fl o operator. .Pp Note that all file tests with the exception of .Fl h and .Fl L follow symbolic links and thus evaluate the test for the file pointed at. .Sh EXIT STATUS The .Nm utility exits with one of the following values: .Bl -tag -width Ds .It 0 .Ar expression evaluated to true. .It 1 .Ar expression evaluated to false or was missing. .It >1 An error occurred. .El .Sh STANDARDS The .Nm utility implements a superset of the .St -p1003.2 specification. .Sh HISTORY A .Nm utility appeared in .At v7 . .Sh CAVEATS The .Nm grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in .St -p1003.2 section 4.62.4, are evaluated consistently according to the rules specified in the standards document. All other cases are subject to the ambiguity in the command semantics. .Pp This means that .Nm should not be used with more than 4 operands (where the terminating .Cm \&] in the case of the .Nm \&[ command does not count as an operand,) and that the obsolete .Fl a and .Fl o options should not be used. Instead invoke .Nm multiple times connected by the .Dq && and .Dq || operators from .Xr sh 1 . When those operators are not used, there is no need for the parentheses as grouping symbols, so those should also be avoided. Using .Xr sh 1 Ns 's .Cm \&! command instead of the equivalent operator from .Nm can also protect the script from future test enhancements. .Pp Most expressions with 3 or less operands will evaluate as expected, though be aware that with 3 operands, if the second is a known binary operator, that is always evaluated, regardless of what the other operands might suggest had been intended. If, and only if, the middle operand is not a defined binary operator is the first operand examined to see if it is .Cm \&! in which case the remaining operands are evaluated as a two operand test, and the result inverted. The only other defined three operand case is the meaningless degenerate case where parentheses (1st and 3rd operands) surround a one operand expression. .Pp With 4 operands there are just two defined cases, the first where the first operand is .Cm \&! in which case the result of the three operand test on the remaining operands is inverted, and the second is similar to the 3 operand case, the degenerate case of parentheses surrounding an (in this case) 2 operand test expression. @ 1.33.4.1 log @Sync with HEAD @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.33 2017/10/18 18:11:54 wiz Exp $ @ 1.33.4.2 log @Ooops, restore accidently removed files from merge mishap @ text @@ 1.32 log @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. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.31 2017/07/03 21:33:24 wiz Exp $ d111 1 a111 2 exists and is a named pipe .Po Tn FIFO Pc . @ 1.31 log @Remove workaround for ancient HTML generation code. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.30 2016/08/12 03:17:41 sevan Exp $ d35 1 a35 1 .Dd August 12, 2016 d331 54 @ 1.30 log @Document the version test first appeared. Bump date. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.29 2016/05/27 05:50:07 dholland Exp $ d209 1 a209 1 .It Ar \&s\&1 Cm \&\*[Lt] Ar \&s\&2 d215 1 a215 1 .It Ar \&s\&1 Cm \&\*[Gt] Ar \&s\&2 d307 1 a307 1 .It \*[Gt]1 @ 1.29 log @usage nit @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.28 2012/12/16 17:57:49 wiz Exp $ d35 1 a35 1 .Dd December 16, 2012 d316 5 @ 1.28 log @- Remove unneeded consecutive argument in `.Nm' macros; - rename `GRAMMAR AMBIGUITY' section to `CAVEATS', and move it to correct location; - bump date. From Bug Hunting. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.27 2009/11/10 18:19:46 wiz Exp $ d278 1 a278 1 are true. @ 1.27 log @Correct usage for parentheses, and mark up "expression" in more places. From Bug Hunting in PR 42286. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.26 2009/05/06 08:26:43 wiz Exp $ d35 1 a35 1 .Dd November 10, 2009 d43 1 a43 1 .Nm test d49 1 a49 1 .Nm test d58 1 a58 1 .Nm test d63 1 a63 1 .Nm test a295 10 .Sh GRAMMAR AMBIGUITY The .Nm test grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in .St -p1003.2 section 4.62.4, are evaluated consistently according to the rules specified in the standards document. All other cases are subject to the ambiguity in the command semantics. d298 1 a298 1 .Nm test d312 1 a312 1 .Nm test d316 10 @ 1.27.12.1 log @resync with head @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.27 2009/11/10 18:19:46 wiz Exp $ d35 1 a35 1 .Dd December 16, 2012 d43 1 a43 1 .Nm d49 1 a49 1 .Nm d58 1 a58 1 .Nm d63 1 a63 1 .Nm d296 10 d308 1 a308 1 .Nm d322 1 a322 1 .Nm a325 10 .Sh CAVEATS The .Nm grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in .St -p1003.2 section 4.62.4, are evaluated consistently according to the rules specified in the standards document. All other cases are subject to the ambiguity in the command semantics. @ 1.27.6.1 log @sync with head @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.27 2009/11/10 18:19:46 wiz Exp $ d35 1 a35 1 .Dd December 16, 2012 d43 1 a43 1 .Nm d49 1 a49 1 .Nm d58 1 a58 1 .Nm d63 1 a63 1 .Nm d296 10 d308 1 a308 1 .Nm d322 1 a322 1 .Nm a325 10 .Sh CAVEATS The .Nm grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in .St -p1003.2 section 4.62.4, are evaluated consistently according to the rules specified in the standards document. All other cases are subject to the ambiguity in the command semantics. @ 1.26 log @Remove leading zero in Dd argument. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.25 2009/05/05 19:04:01 jschauma Exp $ d35 1 a35 1 .Dd May 5, 2009 d50 3 a52 1 utility evaluates the expression and, if it evaluates d55 5 a59 1 If there is no expression, test also d66 2 a67 1 The following primaries are used to construct expression: d279 4 a282 2 .It Cm \&( Ns Ar expression Ns Cm \&) True if expression is true. d312 2 a313 1 expression evaluated to true. d315 2 a316 2 expression evaluated to false or expression was missing. @ 1.25 log @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. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.24 2009/04/12 13:52:20 joerg Exp $ d35 1 a35 1 .Dd May 05, 2009 @ 1.24 log @Fix markup. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.23 2007/05/15 22:00:51 uwe Exp $ d35 1 a35 1 .Dd May 31, 1993 d281 6 @ 1.23 log @Use the same wording for '-p' as for other file related tests. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.22 2006/09/24 13:24:08 hubertf Exp $ d46 1 a46 1 .Ar expression Cm ] @ 1.23.20.1 log @Sync with HEAD. Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.26 2009/05/06 08:26:43 wiz Exp $ d35 1 a35 1 .Dd May 5, 2009 d46 1 a46 1 .Ar expression Cm \&] a280 6 .Pp Note that all file tests with the exception of .Fl h and .Fl L follow symbolic links and thus evaluate the test for the file pointed at. @ 1.22 log @Revert previous (==) - not worth the trouble. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.19 2003/08/07 09:05:43 agc Exp $ d104 1 a104 1 is a named pipe @ 1.21 log @Bump date for previous. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.20 2006/09/22 22:15:24 hubertf Exp $ d35 1 a35 1 .Dd September 22, 2006 a195 3 .It Ar \&s\&1 Cm \&== Ar \&s\&2 A synonym for .Cm \&= . @ 1.20 log @Allow '==' as synonym to '=', just like our ksh and bash do. This also affects the sh(1) builtin test command. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.19 2003/08/07 09:05:43 agc Exp $ d35 1 a35 1 .Dd May 31, 1993 @ 1.19 log @Move UCB-licensed code from 4-clause to 3-clause licence. Patches provided by Joel Baker in PR 22249, verified by myself. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.18 2002/09/25 15:18:44 wiz Exp $ d196 3 @ 1.18 log @New policy: New sentences start on a new line. Patches by Robert Elz , with minimal changes by me. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.17 2002/02/08 01:22:01 ross Exp $ d17 1 a17 5 .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors @ 1.17 log @Generate <>& symbolically. I'm avoiding .../dist/... directories for now. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.16 2001/12/20 19:31:52 wiz Exp $ d157 2 a158 1 this program. Do not rely on its existence; use d288 2 a289 2 grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in d293 2 a294 2 standards document. All other cases are subject to the ambiguity in the command semantics. @ 1.16 log @Whitespace nits. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.15 2001/10/17 21:14:45 wiz Exp $ d205 1 a205 1 .It Ar \&s\&1 Cm \&< Ar \&s\&2 d211 1 a211 1 .It Ar \&s\&1 Cm \&> Ar \&s\&2 d304 1 a304 1 .It >1 @ 1.15 log @Properly quote `[' as macro argument. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.14 2000/09/04 07:30:13 kleink Exp $ d112 1 a112 1 .Ar file d153 1 a153 1 True if d217 1 a217 1 .It Ar \&n\&1 Fl \&eq Ar \&n\&2 d285 1 a285 1 The d288 1 a288 1 the cases described in d290 1 a290 1 section 4.62.4, @ 1.14 log @For commands and utilities, use EXIT STATUS rather than RETURN VALUES as appropriate (and documented in mdoc(7)). @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.13 1999/12/17 13:16:44 abs Exp $ d49 1 a49 1 .Nm [ @ 1.13 log @Remove duplicate 'string' / 's1' entry @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.12 1999/08/22 14:06:59 kleink Exp $ d294 1 a294 1 .Sh RETURN VALUES @ 1.12 log @Reverse the advice given to (now) prefer -h over -L; the former is defined in 1003.2bD3 and SVID4 and thus supposedly more portable. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.11 1999/03/09 07:05:33 garbled Exp $ a216 5 .It Ar \&s\&1 True if .Ar \&s\&1 is not the null string. @ 1.12.4.1 log @Pull up to last week's -current. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.13 1999/12/17 13:16:44 abs Exp $ d217 5 @ 1.11 log @the '[' wasn't being displayed properly as a command. Thanks to Charles for the fix. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.10 1997/11/12 00:48:21 mrg Exp $ a96 4 This operator is retained for compatibility with previous versions of this program. Do not rely on its existence; use .Fl L instead. d156 4 @ 1.11.2.1 log @Pull up revision 1.10 (requested by abs): Remove obsolete reference to mkpasswd(8). @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.11 1999/03/09 07:05:33 garbled Exp $ d217 5 @ 1.10 log @add missing .Nm calls and MLINKS. from spz@@serpens.swb.de @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.9 1997/10/09 07:37:09 mycroft Exp $ d44 1 a44 1 .Nm [ @ 1.9 log @Fix format of description line. @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.8 1997/06/05 06:39:59 mikel Exp $ d43 2 a44 1 .Nm test @ 1.9.2.1 log @pull up from trunk: add missing .Nm calls and MLINKS. from spz@@serpens.swb.de @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.9 1997/10/09 07:37:09 mycroft Exp $ d43 1 a43 2 .Nm test , .Nm [ @ 1.8 log @add SYNOPSIS line for [; fixes PR bin/3705 @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.7 1996/01/05 12:39:30 pk Exp $ d44 1 a44 1 .Nd Condition evaluation utility. @ 1.7 log @Note compatibility `-h' op. (from Rob Windsor; PR#1740) @ text @d1 1 a1 1 .\" $NetBSD: test.1,v 1.6 1995/03/21 07:04:03 cgd Exp $ d48 2 @ 1.6 log @clean up Id's, and such. reorganize man page slight to match lite's org. @ text @d1 1 a1 1 .\" $NetBSD$ d90 8 @ 1.5 log @Replaced test with simpler, more feature rich, version derived from pdksh. @ text @d1 4 a4 2 .\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. d37 1 a37 2 .\" from: @@(#)test.1 6.6 (Berkeley) 6/8/92 .\" $Id: test.1,v 1.3 1994/02/19 06:29:02 cgd Exp $ d39 1 a39 1 .Dd June 8, 1992 d278 10 a306 10 .Sh BUGS The .Nm test grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in .St -p1003.2 section 4.62.4, are evaluated consistently according to the rules specified in the standards document. All other cases are subject to the ambiguity in the command semantics. @ 1.4 log @The file_descriptor argument to the -t primary is no longer optional. @ text @d89 1 a89 1 .It Fl h Ar file d92 1 a92 1 exists and is a symbolic link. d104 2 a105 1 .Ar file exists and is readable. d144 32 d193 17 a276 10 .Sh GRAMMAR AMBIGUITY The .Nm test grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in the .St -p1003.2 , section D11.2/4.62.4, standard are evaluated consistently according to the rules specified in the standards document. All other cases are subject to the ambiguity in the command semantics. d293 8 a300 1 function is expected to be d302 4 a305 1 compatible. @ 1.3 log @add support for 'test -h' a la SunOS @ text @d36 1 a36 1 .\" $Id: test.1,v 1.2 1993/08/01 07:47:45 mycroft Exp $ d110 1 a110 1 .It Fl t Ar [file_descriptor] d114 1 a114 2 (default 1) is open and is associated with a terminal. @ 1.2 log @Add RCS indentifiers. @ text @d36 1 a36 1 .\" $Id: $ d89 4 @ 1.1 log @new 'test' from ftp.uu.net:/systems/unix/bsd-sources, got rid of GNU thing @ text @d35 2 a36 1 .\" @@(#)test.1 6.6 (Berkeley) 6/8/92 @