| 1 |
test-about = Check file types and compare values. |
| 2 |
test-usage = test EXPRESSION |
| 3 |
test |
| 4 |
{"[ EXPRESSION ]"} |
| 5 |
{"[ ]"} |
| 6 |
{"[ OPTION"} |
| 7 |
test-after-help = Exit with the status determined by EXPRESSION. |
| 8 |
|
| 9 |
An omitted EXPRESSION defaults to false. |
| 10 |
Otherwise, EXPRESSION is true or false and sets exit status. |
| 11 |
It is one of: |
| 12 |
|
| 13 |
( EXPRESSION ) |
| 14 |
EXPRESSION is true |
| 15 |
|
| 16 |
! EXPRESSION |
| 17 |
EXPRESSION is false |
| 18 |
|
| 19 |
EXPRESSION1 -a EXPRESSION2 |
| 20 |
both EXPRESSION1 and EXPRESSION2 are true |
| 21 |
|
| 22 |
EXPRESSION1 -o EXPRESSION2 |
| 23 |
either EXPRESSION1 or EXPRESSION2 is true |
| 24 |
|
| 25 |
String operations: |
| 26 |
|
| 27 |
-n STRING |
| 28 |
the length of STRING is nonzero |
| 29 |
|
| 30 |
STRING |
| 31 |
equivalent to -n STRING |
| 32 |
|
| 33 |
-z STRING |
| 34 |
the length of STRING is zero |
| 35 |
|
| 36 |
STRING1 = STRING2 |
| 37 |
the strings are equal |
| 38 |
|
| 39 |
STRING1 != STRING2 |
| 40 |
the strings are not equal |
| 41 |
|
| 42 |
STRING1 > STRING2 |
| 43 |
STRING1 is greater than STRING2 in the current locale |
| 44 |
|
| 45 |
STRING1 < STRING2 |
| 46 |
STRING1 is less than STRING2 in the current locale |
| 47 |
|
| 48 |
Integer comparisons: |
| 49 |
|
| 50 |
INTEGER1 -eq INTEGER2 |
| 51 |
INTEGER1 is equal to INTEGER2 |
| 52 |
|
| 53 |
INTEGER1 -ge INTEGER2 |
| 54 |
INTEGER1 is greater than or equal to INTEGER2 |
| 55 |
|
| 56 |
INTEGER1 -gt INTEGER2 |
| 57 |
INTEGER1 is greater than INTEGER2 |
| 58 |
|
| 59 |
INTEGER1 -le INTEGER2 |
| 60 |
INTEGER1 is less than or equal to INTEGER2 |
| 61 |
|
| 62 |
INTEGER1 -lt INTEGER2 |
| 63 |
INTEGER1 is less than INTEGER2 |
| 64 |
|
| 65 |
INTEGER1 -ne INTEGER2 |
| 66 |
INTEGER1 is not equal to INTEGER2 |
| 67 |
|
| 68 |
File operations: |
| 69 |
|
| 70 |
FILE1 -ef FILE2 |
| 71 |
FILE1 and FILE2 have the same device and inode numbers |
| 72 |
|
| 73 |
FILE1 -nt FILE2 |
| 74 |
FILE1 is newer (modification date) than FILE2 |
| 75 |
|
| 76 |
FILE1 -ot FILE2 |
| 77 |
FILE1 is older than FILE2 |
| 78 |
|
| 79 |
-b FILE |
| 80 |
FILE exists and is block special |
| 81 |
|
| 82 |
-c FILE |
| 83 |
FILE exists and is character special |
| 84 |
|
| 85 |
-d FILE |
| 86 |
FILE exists and is a directory |
| 87 |
|
| 88 |
-e FILE |
| 89 |
FILE exists |
| 90 |
|
| 91 |
-f FILE |
| 92 |
FILE exists and is a regular file |
| 93 |
|
| 94 |
-g FILE |
| 95 |
FILE exists and is set-group-ID |
| 96 |
|
| 97 |
-G FILE |
| 98 |
FILE exists and is owned by the effective group ID |
| 99 |
|
| 100 |
-h FILE |
| 101 |
FILE exists and is a symbolic link (same as -L) |
| 102 |
|
| 103 |
-k FILE |
| 104 |
FILE exists and has its sticky bit set |
| 105 |
|
| 106 |
-L FILE |
| 107 |
FILE exists and is a symbolic link (same as -h) |
| 108 |
|
| 109 |
-N FILE |
| 110 |
FILE exists and has been modified since it was last read |
| 111 |
|
| 112 |
-O FILE |
| 113 |
FILE exists and is owned by the effective user ID |
| 114 |
|
| 115 |
-p FILE |
| 116 |
FILE exists and is a named pipe |
| 117 |
|
| 118 |
-r FILE |
| 119 |
FILE exists and read permission is granted |
| 120 |
|
| 121 |
-s FILE |
| 122 |
FILE exists and has a size greater than zero |
| 123 |
|
| 124 |
-S FILE |
| 125 |
FILE exists and is a socket |
| 126 |
|
| 127 |
-t FD |
| 128 |
file descriptor FD is opened on a terminal |
| 129 |
|
| 130 |
-u FILE |
| 131 |
FILE exists and its set-user-ID bit is set |
| 132 |
|
| 133 |
-w FILE |
| 134 |
FILE exists and write permission is granted |
| 135 |
|
| 136 |
-x FILE |
| 137 |
FILE exists and execute (or search) permission is granted |
| 138 |
|
| 139 |
Except for -h and -L, all FILE-related tests dereference (follow) symbolic links. |
| 140 |
Beware that parentheses need to be escaped (e.g., by backslashes) for shells. |
| 141 |
INTEGER may also be -l STRING, which evaluates to the length of STRING. |
| 142 |
|
| 143 |
NOTE: Binary -a and -o are inherently ambiguous. |
| 144 |
Use test EXPR1 && test EXPR2 or test EXPR1 || test EXPR2 instead. |
| 145 |
|
| 146 |
NOTE: {"["} honors the --help and --version options, but test does not. |
| 147 |
test treats each of those as it treats any other nonempty STRING. |
| 148 |
|
| 149 |
NOTE: your shell may have its own version of test and/or {"["}, which usually supersedes the version described here. |
| 150 |
Please refer to your shell's documentation for details about the options it supports. |
| 151 |
|
| 152 |
Errors are reported with the expression echoed back and a caret under the |
| 153 |
argument at fault whenever stderr is a terminal; anything else reading |
| 154 |
stderr gets the usual single-line message. |
| 155 |
|
| 156 |
# Error messages |
| 157 |
test-error-missing-closing-bracket = missing '{"]"}' |
| 158 |
test-error-expected = expected { $value } |
| 159 |
test-error-expected-value = expected value |
| 160 |
test-error-missing-argument = missing argument after { $argument } |
| 161 |
test-error-extra-argument = extra argument { $argument } |
| 162 |
test-error-unknown-operator = unknown operator { $operator } |
| 163 |
test-error-invalid-integer = invalid integer { $value } |
| 164 |
test-error-unary-operator-expected = { $operator }: unary operator expected |
| 165 |
|
| 166 |
# Diagnostic labels, used when errors are rendered with a source snippet |
| 167 |
test-diag-label-unary-operator-expected = this needs an expression on both sides |
| 168 |
test-diag-help-integer-op = -eq, -ne, -lt, -le, -gt and -ge compare integers; use =, {"!"}=, {"<"} or {">"} to compare strings |
| 169 |
test-diag-help-integer-op-mnemonics = -eq equal, -ne not equal, -lt less than, -le less than or equal, -gt greater than, -ge greater than or equal |
| 170 |
test-diag-help-file-descriptor = -t takes a file descriptor number: 0 is standard input, 1 standard output, 2 standard error |
| 171 |
test-diag-help-missing-argument = an unset or empty variable expands to nothing, leaving the operator without an operand; quote it as "$var" |
| 172 |
test-diag-help-extra-argument = an unquoted variable expanding to several words is the usual cause; quote it as "$var" to keep it a single operand |
| 173 |
test-diag-help-unknown-operator = run '{ $name } --help' for the list of supported operators |