Annotation of lucent/sys/man/1/test, revision 1.1

1.1     ! root        1: .TH TEST 1
        !             2: .SH NAME
        !             3: test \- set status according to condition
        !             4: .SH SYNOPSIS
        !             5: .B test
        !             6: .I expr
        !             7: .SH DESCRIPTION
        !             8: .I Test
        !             9: evaluates the expression
        !            10: .IR expr .
        !            11: If the value is true the exit status is null; otherwise the
        !            12: exit status is non-null.
        !            13: If there are no arguments the exit status is non-null.
        !            14: .PP
        !            15: The following primitives are used to construct
        !            16: .IR expr .
        !            17: .TP "\w'\fIn1 \fL-eq \fIn2\fLXX'u"
        !            18: .BI -r " file"
        !            19: True if the file exists (is accessible) and is readable.
        !            20: .PD0
        !            21: .TP
        !            22: .BI -w " file"
        !            23: True if the file exists and is writable.
        !            24: .TP
        !            25: .BI -x " file"
        !            26: True if the file exists and has execute permission.
        !            27: .TP
        !            28: .BI -e " file
        !            29: True if the file exists.
        !            30: .TP
        !            31: .BI -f " file"
        !            32: True if the file exists and is a plain file.
        !            33: .TP
        !            34: .BI -d " file"
        !            35: True if the file exists and is a directory.
        !            36: .TP
        !            37: .BI -s " file"
        !            38: True if the file exists and has a size greater than zero.
        !            39: .TP
        !            40: .BI -t " fildes
        !            41: True if the open file whose file descriptor number is
        !            42: .I fildes
        !            43: (1 by default)
        !            44: is the same file as
        !            45: .BR /dev/cons .
        !            46: .TP
        !            47: .IB s1 " = " s2
        !            48: True
        !            49: if the strings
        !            50: .I s1
        !            51: and
        !            52: .I s2
        !            53: are identical.
        !            54: .TP
        !            55: .IB s1 " != " s2
        !            56: True
        !            57: if the strings
        !            58: .I s1
        !            59: and
        !            60: .I s2
        !            61: are not identical.
        !            62: .TP
        !            63: s1
        !            64: True if
        !            65: .I s1
        !            66: is not the null string.
        !            67: (Deprecated.)
        !            68: .TP
        !            69: .BI -n " s1"
        !            70: True if the length of string
        !            71: .I s1
        !            72: is non-zero.
        !            73: .TP
        !            74: .BI -z " s1"
        !            75: True if the length of string
        !            76: .I s1
        !            77: is zero.
        !            78: .TP
        !            79: .IB n1 " -eq " n2
        !            80: True if the integers
        !            81: .I n1
        !            82: and
        !            83: .I n2
        !            84: are arithmetically equal.
        !            85: Any of the comparisons
        !            86: .BR -ne ,
        !            87: .BR -gt ,
        !            88: .BR -ge ,
        !            89: .BR -lt ,
        !            90: or
        !            91: .BR -le
        !            92: may be used in place of
        !            93: .BR -eq .
        !            94: The (nonstandard) construct
        !            95: .BI -l " string\f1,
        !            96: meaning the length of
        !            97: .IR string ,
        !            98: may be used in place of an integer.
        !            99: .PD
        !           100: .PP
        !           101: These primaries may be combined with the
        !           102: following operators:
        !           103: .TP "\w'\fL( \fIexpr\fL )XX'u"
        !           104: .B  !
        !           105: unary negation operator
        !           106: .PD0
        !           107: .TP
        !           108: .B  -o
        !           109: binary
        !           110: .I or
        !           111: operator
        !           112: .TP
        !           113: .B  -a
        !           114: binary
        !           115: .I and
        !           116: operator; higher precedence than
        !           117: .BR -o
        !           118: .TP
        !           119: .BI "( " expr " )"
        !           120: parentheses for grouping.
        !           121: .PD
        !           122: .PP
        !           123: The primitives
        !           124: .BR -b ,
        !           125: .BR -u ,
        !           126: .BR -g ,
        !           127: and
        !           128: .BR -s
        !           129: return false; they are recognized for compatibility with POSIX.
        !           130: .PP
        !           131: Notice that all the operators and flags are separate
        !           132: arguments to
        !           133: .IR test .
        !           134: Notice also that parentheses and equal signs are meaningful
        !           135: to
        !           136: .I rc
        !           137: and must be enclosed in quotes.
        !           138: .SH EXAMPLES
        !           139: .I Test
        !           140: is a dubious way to check for specific character strings:
        !           141: it uses a process to do what an
        !           142: .IR rc (1)
        !           143: match or switch statement can do.
        !           144: The first example is not only inefficient but wrong, because
        !           145: .I test
        !           146: understands the purported string
        !           147: .B  \&"-c"
        !           148: as an option.
        !           149: .IP
        !           150: .EX
        !           151: if (test $1 '=' "-c") echo OK  # wrong!
        !           152: .EE
        !           153: .LP
        !           154: A better way is
        !           155: .IP
        !           156: .EX
        !           157: if (~ $1 -c) echo OK
        !           158: .EE
        !           159: .PP
        !           160: Test whether 
        !           161: .L abc
        !           162: is in the current directory.
        !           163: .IP
        !           164: .B test -f abc -o -d abc
        !           165: .SH SOURCE
        !           166: .B /sys/src/cmd/test.c
        !           167: .SH "SEE ALSO"
        !           168: .IR rc (1) 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.