14b88c807SRodney W. Grimes.\" Copyright (c) 1991, 1993 24b88c807SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 34b88c807SRodney W. Grimes.\" 44b88c807SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 54b88c807SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc. 64b88c807SRodney W. Grimes.\" 74b88c807SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 84b88c807SRodney W. Grimes.\" modification, are permitted provided that the following conditions 94b88c807SRodney W. Grimes.\" are met: 104b88c807SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 114b88c807SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 124b88c807SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 134b88c807SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 144b88c807SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 154b88c807SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 164b88c807SRodney W. Grimes.\" must display the following acknowledgement: 174b88c807SRodney W. Grimes.\" This product includes software developed by the University of 184b88c807SRodney W. Grimes.\" California, Berkeley and its contributors. 194b88c807SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 204b88c807SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 214b88c807SRodney W. Grimes.\" without specific prior written permission. 224b88c807SRodney W. Grimes.\" 234b88c807SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 244b88c807SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 254b88c807SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 264b88c807SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 274b88c807SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 284b88c807SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 294b88c807SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 304b88c807SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 314b88c807SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 324b88c807SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 334b88c807SRodney W. Grimes.\" SUCH DAMAGE. 344b88c807SRodney W. Grimes.\" 354b88c807SRodney W. Grimes.\" @(#)test.1 8.1 (Berkeley) 5/31/93 362a456239SPeter Wemm.\" $FreeBSD$ 374b88c807SRodney W. Grimes.\" 384b88c807SRodney W. Grimes.Dd May 31, 1993 394b88c807SRodney W. Grimes.Dt TEST 1 404b88c807SRodney W. Grimes.Os 414b88c807SRodney W. Grimes.Sh NAME 42717a08b6SSheldon Hearn.Nm test , 43717a08b6SSheldon Hearn.Nm \&[ 444b88c807SRodney W. Grimes.Nd condition evaluation utility 454b88c807SRodney W. Grimes.Sh SYNOPSIS 46be8b1497SRuslan Ermilov.Nm 474b88c807SRodney W. Grimes.Ar expression 48238fe5f7SRuslan Ermilov.Nm \&[ 49717a08b6SSheldon Hearn.Ar expression Cm ] 504b88c807SRodney W. Grimes.Sh DESCRIPTION 514b88c807SRodney W. GrimesThe 52be8b1497SRuslan Ermilov.Nm 534b88c807SRodney W. Grimesutility evaluates the expression and, if it evaluates 544b88c807SRodney W. Grimesto true, returns a zero (true) exit status; otherwise 554b88c807SRodney W. Grimesit returns 1 (false). 564b88c807SRodney W. GrimesIf there is no expression, test also 574b88c807SRodney W. Grimesreturns 1 (false). 584b88c807SRodney W. Grimes.Pp 594b88c807SRodney W. GrimesAll operators and flags are separate arguments to the 60be8b1497SRuslan Ermilov.Nm 614b88c807SRodney W. Grimesutility. 624b88c807SRodney W. Grimes.Pp 634b88c807SRodney W. GrimesThe following primaries are used to construct expression: 64717a08b6SSheldon Hearn.Bl -tag -width Ar 654b88c807SRodney W. Grimes.It Fl b Ar file 664b88c807SRodney W. GrimesTrue if 674b88c807SRodney W. Grimes.Ar file 684b88c807SRodney W. Grimesexists and is a block special 694b88c807SRodney W. Grimesfile. 704b88c807SRodney W. Grimes.It Fl c Ar file 714b88c807SRodney W. GrimesTrue if 724b88c807SRodney W. Grimes.Ar file 734b88c807SRodney W. Grimesexists and is a character 744b88c807SRodney W. Grimesspecial file. 754b88c807SRodney W. Grimes.It Fl d Ar file 764b88c807SRodney W. GrimesTrue if 774b88c807SRodney W. Grimes.Ar file 784b88c807SRodney W. Grimesexists and is a directory. 794b88c807SRodney W. Grimes.It Fl e Ar file 804b88c807SRodney W. GrimesTrue if 814b88c807SRodney W. Grimes.Ar file 824b88c807SRodney W. Grimesexists (regardless of type). 834b88c807SRodney W. Grimes.It Fl f Ar file 844b88c807SRodney W. GrimesTrue if 854b88c807SRodney W. Grimes.Ar file 864b88c807SRodney W. Grimesexists and is a regular file. 874b88c807SRodney W. Grimes.It Fl g Ar file 884b88c807SRodney W. GrimesTrue if 894b88c807SRodney W. Grimes.Ar file 904b88c807SRodney W. Grimesexists and its set group ID flag 914b88c807SRodney W. Grimesis set. 924b88c807SRodney W. Grimes.It Fl h Ar file 934b88c807SRodney W. GrimesTrue if 944b88c807SRodney W. Grimes.Ar file 954b88c807SRodney W. Grimesexists and is a symbolic link. 96717a08b6SSheldon HearnThis operator is retained for compatibility with previous versions of 97bef84d6bSSheldon Hearnthis program. 98bef84d6bSSheldon HearnDo not rely on its existence; use 99717a08b6SSheldon Hearn.Fl L 100717a08b6SSheldon Hearninstead. 101717a08b6SSheldon Hearn.It Fl k Ar file 102717a08b6SSheldon HearnTrue if 103717a08b6SSheldon Hearn.Ar file 104717a08b6SSheldon Hearnexists and its sticky bit is set. 1054b88c807SRodney W. Grimes.It Fl n Ar string 1064b88c807SRodney W. GrimesTrue if the length of 1074b88c807SRodney W. Grimes.Ar string 1084b88c807SRodney W. Grimesis nonzero. 1094b88c807SRodney W. Grimes.It Fl p Ar file 1104b88c807SRodney W. GrimesTrue if 1114b88c807SRodney W. Grimes.Ar file 1124b88c807SRodney W. Grimesis a named pipe 113c4d9468eSRuslan Ermilov.Pq Tn FIFO . 1144b88c807SRodney W. Grimes.It Fl r Ar file 1154b88c807SRodney W. GrimesTrue if 116c263cc21SPhilippe Charnier.Ar file 117c263cc21SPhilippe Charnierexists and is readable. 1184b88c807SRodney W. Grimes.It Fl s Ar file 1194b88c807SRodney W. GrimesTrue if 1204b88c807SRodney W. Grimes.Ar file 1214b88c807SRodney W. Grimesexists and has a size greater 1224b88c807SRodney W. Grimesthan zero. 123717a08b6SSheldon Hearn.It Fl t Op Ar file_descriptor 1244b88c807SRodney W. GrimesTrue if the file whose file descriptor number 1254b88c807SRodney W. Grimesis 1264b88c807SRodney W. Grimes.Ar file_descriptor 127717a08b6SSheldon Hearnis open and is associated with a terminal. 1284b88c807SRodney W. Grimes.It Fl u Ar file 1294b88c807SRodney W. GrimesTrue if 1304b88c807SRodney W. Grimes.Ar file 1314b88c807SRodney W. Grimesexists and its set user ID flag 1324b88c807SRodney W. Grimesis set. 1334b88c807SRodney W. Grimes.It Fl w Ar file 1344b88c807SRodney W. GrimesTrue if 1354b88c807SRodney W. Grimes.Ar file 1364b88c807SRodney W. Grimesexists and is writable. 1374b88c807SRodney W. GrimesTrue 1384b88c807SRodney W. Grimesindicates only that the write flag is on. 1394b88c807SRodney W. GrimesThe file is not writable on a read-only file 1404b88c807SRodney W. Grimessystem even if this test indicates true. 1414b88c807SRodney W. Grimes.It Fl x Ar file 1424b88c807SRodney W. GrimesTrue if 1434b88c807SRodney W. Grimes.Ar file 1444b88c807SRodney W. Grimesexists and is executable. 1454b88c807SRodney W. GrimesTrue 1464b88c807SRodney W. Grimesindicates only that the execute flag is on. 1474b88c807SRodney W. GrimesIf 1484b88c807SRodney W. Grimes.Ar file 1494b88c807SRodney W. Grimesis a directory, true indicates that 1504b88c807SRodney W. Grimes.Ar file 1514b88c807SRodney W. Grimescan be searched. 1524b88c807SRodney W. Grimes.It Fl z Ar string 1534b88c807SRodney W. GrimesTrue if the length of 1544b88c807SRodney W. Grimes.Ar string 1554b88c807SRodney W. Grimesis zero. 156717a08b6SSheldon Hearn.It Fl L Ar file 157717a08b6SSheldon HearnTrue if 158717a08b6SSheldon Hearn.Ar file 159717a08b6SSheldon Hearnexists and is a symbolic link. 160717a08b6SSheldon Hearn.It Fl O Ar file 161717a08b6SSheldon HearnTrue if 162717a08b6SSheldon Hearn.Ar file 163717a08b6SSheldon Hearnexists and its owner matches the effective user id of this process. 164717a08b6SSheldon Hearn.It Fl G Ar file 165717a08b6SSheldon HearnTrue if 166717a08b6SSheldon Hearn.Ar file 167717a08b6SSheldon Hearnexists and its group matches the effective group id of this process. 168717a08b6SSheldon Hearn.It Fl S Ar file 169717a08b6SSheldon HearnTrue if 170717a08b6SSheldon Hearn.Ar file 171717a08b6SSheldon Hearnexists and is a socket. 172717a08b6SSheldon Hearn.It Ar file1 Fl nt Ar file2 173717a08b6SSheldon HearnTrue if 174717a08b6SSheldon Hearn.Ar file1 175717a08b6SSheldon Hearnexists and is newer than 176717a08b6SSheldon Hearn.Ar file2 . 177717a08b6SSheldon Hearn.It Ar file1 Fl ot Ar file2 178717a08b6SSheldon HearnTrue if 179717a08b6SSheldon Hearn.Ar file1 180717a08b6SSheldon Hearnexists and is older than 181717a08b6SSheldon Hearn.Ar file2 . 182717a08b6SSheldon Hearn.It Ar file1 Fl ef Ar file2 183717a08b6SSheldon HearnTrue if 184717a08b6SSheldon Hearn.Ar file1 185717a08b6SSheldon Hearnand 186717a08b6SSheldon Hearn.Ar file2 187717a08b6SSheldon Hearnexist and refer to the same file. 1884b88c807SRodney W. Grimes.It Ar string 1894b88c807SRodney W. GrimesTrue if 1904b88c807SRodney W. Grimes.Ar string 1914b88c807SRodney W. Grimesis not the null 1924b88c807SRodney W. Grimesstring. 1934b88c807SRodney W. Grimes.It Ar \&s\&1 Cm \&= Ar \&s\&2 1944b88c807SRodney W. GrimesTrue if the strings 1954b88c807SRodney W. Grimes.Ar \&s\&1 1964b88c807SRodney W. Grimesand 1974b88c807SRodney W. Grimes.Ar \&s\&2 1984b88c807SRodney W. Grimesare identical. 1994b88c807SRodney W. Grimes.It Ar \&s\&1 Cm \&!= Ar \&s\&2 2004b88c807SRodney W. GrimesTrue if the strings 2014b88c807SRodney W. Grimes.Ar \&s\&1 2024b88c807SRodney W. Grimesand 2034b88c807SRodney W. Grimes.Ar \&s\&2 2044b88c807SRodney W. Grimesare not identical. 205717a08b6SSheldon Hearn.It Ar \&s\&1 Cm \&< Ar \&s\&2 206717a08b6SSheldon HearnTrue if string 207717a08b6SSheldon Hearn.Ar \&s\&1 208717a08b6SSheldon Hearncomes before 209717a08b6SSheldon Hearn.Ar \&s\&2 210717a08b6SSheldon Hearnbased on the ASCII value of their characters. 211717a08b6SSheldon Hearn.It Ar \&s\&1 Cm \&> Ar \&s\&2 212717a08b6SSheldon HearnTrue if string 213717a08b6SSheldon Hearn.Ar \&s\&1 214717a08b6SSheldon Hearncomes after 215717a08b6SSheldon Hearn.Ar \&s\&2 216717a08b6SSheldon Hearnbased on the ASCII value of their characters. 217717a08b6SSheldon Hearn.It Ar \&s\&1 218717a08b6SSheldon HearnTrue if 219717a08b6SSheldon Hearn.Ar \&s\&1 220717a08b6SSheldon Hearnis not the null 221717a08b6SSheldon Hearnstring. 2224b88c807SRodney W. Grimes.It Ar \&n\&1 Fl \&eq Ar \&n\&2 2234b88c807SRodney W. GrimesTrue if the integers 2244b88c807SRodney W. Grimes.Ar \&n\&1 2254b88c807SRodney W. Grimesand 2264b88c807SRodney W. Grimes.Ar \&n\&2 2274b88c807SRodney W. Grimesare algebraically 2284b88c807SRodney W. Grimesequal. 2294b88c807SRodney W. Grimes.It Ar \&n\&1 Fl \&ne Ar \&n\&2 2304b88c807SRodney W. GrimesTrue if the integers 2314b88c807SRodney W. Grimes.Ar \&n\&1 2324b88c807SRodney W. Grimesand 2334b88c807SRodney W. Grimes.Ar \&n\&2 2344b88c807SRodney W. Grimesare not 2354b88c807SRodney W. Grimesalgebraically equal. 2364b88c807SRodney W. Grimes.It Ar \&n\&1 Fl \> Ar \&n\&2 2374b88c807SRodney W. GrimesTrue if the integer 2384b88c807SRodney W. Grimes.Ar \&n\&1 2394b88c807SRodney W. Grimesis algebraically 2404b88c807SRodney W. Grimesgreater than the integer 2414b88c807SRodney W. Grimes.Ar \&n\&2 . 2424b88c807SRodney W. Grimes.It Ar \&n\&1 Fl \&ge Ar \&n\&2 2434b88c807SRodney W. GrimesTrue if the integer 2444b88c807SRodney W. Grimes.Ar \&n\&1 2454b88c807SRodney W. Grimesis algebraically 2464b88c807SRodney W. Grimesgreater than or equal to the integer 2474b88c807SRodney W. Grimes.Ar \&n\&2 . 2484b88c807SRodney W. Grimes.It Ar \&n\&1 Fl \< Ar \&n\&2 2494b88c807SRodney W. GrimesTrue if the integer 2504b88c807SRodney W. Grimes.Ar \&n\&1 2514b88c807SRodney W. Grimesis algebraically less 2524b88c807SRodney W. Grimesthan the integer 2534b88c807SRodney W. Grimes.Ar \&n\&2 . 2544b88c807SRodney W. Grimes.It Ar \&n\&1 Fl \&le Ar \&n\&2 2554b88c807SRodney W. GrimesTrue if the integer 2564b88c807SRodney W. Grimes.Ar \&n\&1 2574b88c807SRodney W. Grimesis algebraically less 2584b88c807SRodney W. Grimesthan or equal to the integer 2594b88c807SRodney W. Grimes.Ar \&n\&2 . 2604b88c807SRodney W. Grimes.El 2614b88c807SRodney W. Grimes.Pp 2624b88c807SRodney W. GrimesThese primaries can be combined with the following operators: 2634b88c807SRodney W. Grimes.Bl -tag -width Ar 2644b88c807SRodney W. Grimes.It Cm \&! Ar expression 2654b88c807SRodney W. GrimesTrue if 2664b88c807SRodney W. Grimes.Ar expression 2674b88c807SRodney W. Grimesis false. 2684b88c807SRodney W. Grimes.It Ar expression1 Fl a Ar expression2 2694b88c807SRodney W. GrimesTrue if both 2704b88c807SRodney W. Grimes.Ar expression1 2714b88c807SRodney W. Grimesand 2724b88c807SRodney W. Grimes.Ar expression2 2734b88c807SRodney W. Grimesare true. 2744b88c807SRodney W. Grimes.It Ar expression1 Fl o Ar expression2 2754b88c807SRodney W. GrimesTrue if either 2764b88c807SRodney W. Grimes.Ar expression1 2774b88c807SRodney W. Grimesor 2784b88c807SRodney W. Grimes.Ar expression2 2794b88c807SRodney W. Grimesare true. 2804b88c807SRodney W. Grimes.It Cm \&( Ns Ar expression Ns Cm \&) 2814b88c807SRodney W. GrimesTrue if expression is true. 2824b88c807SRodney W. Grimes.El 2834b88c807SRodney W. Grimes.Pp 2844b88c807SRodney W. GrimesThe 2854b88c807SRodney W. Grimes.Fl a 2864b88c807SRodney W. Grimesoperator has higher precedence than the 2874b88c807SRodney W. Grimes.Fl o 2884b88c807SRodney W. Grimesoperator. 2894b88c807SRodney W. Grimes.Sh GRAMMAR AMBIGUITY 2904b88c807SRodney W. GrimesThe 291be8b1497SRuslan Ermilov.Nm 2924b88c807SRodney W. Grimesgrammar is inherently ambiguous. In order to assure a degree of consistency, 2934b88c807SRodney W. Grimesthe cases described in the 2944b88c807SRodney W. Grimes.St -p1003.2 , 2954b88c807SRodney W. Grimessection D11.2/4.62.4, standard 2964b88c807SRodney W. Grimesare evaluated consistently according to the rules specified in the 2974b88c807SRodney W. Grimesstandards document. All other cases are subject to the ambiguity in the 2984b88c807SRodney W. Grimescommand semantics. 2994b88c807SRodney W. Grimes.Sh RETURN VALUES 3004b88c807SRodney W. GrimesThe 301be8b1497SRuslan Ermilov.Nm 3024b88c807SRodney W. Grimesutility exits with one of the following values: 3034b88c807SRodney W. Grimes.Bl -tag -width Ds 3044b88c807SRodney W. Grimes.It 0 3054b88c807SRodney W. Grimesexpression evaluated to true. 3064b88c807SRodney W. Grimes.It 1 3074b88c807SRodney W. Grimesexpression evaluated to false or expression was 3084b88c807SRodney W. Grimesmissing. 3094b88c807SRodney W. Grimes.It >1 3104b88c807SRodney W. GrimesAn error occurred. 3114b88c807SRodney W. Grimes.El 312e5bf7bf4SJoseph Koshy.Sh SEE ALSO 313e5bf7bf4SJoseph Koshy.Xr expr 1 , 314e5bf7bf4SJoseph Koshy.Xr sh 1 3154b88c807SRodney W. Grimes.Sh STANDARDS 3164b88c807SRodney W. GrimesThe 317be8b1497SRuslan Ermilov.Nm 318717a08b6SSheldon Hearnutility implements a superset of the 3194b88c807SRodney W. Grimes.St -p1003.2 320717a08b6SSheldon Hearnspecification. 321