@@ -8411,8 +8411,123 @@ <h2 id="examples-88"><a class="header" href="#examples-88">Examples</a></h2>
8411
8411
< div class ="version "> v0.0.18
8412
8412
</ div >
8413
8413
</ div >
8414
+ < pre > < code > test EXPRESSION
8415
+ test
8416
+ test EXPRESSION ]
8417
+ test ]
8418
+ test OPTION
8419
+ </ code > </ pre >
8420
+ < p > Check file types and compare values.</ p >
8414
8421
< h2 id ="options-99 "> < a class ="header " href ="#options-99 "> Options</ a > </ h2 >
8415
8422
< dl > </ dl >
8423
+ < p > Exit with the status determined by < code > EXPRESSION</ code > .</ p >
8424
+ < p > An omitted < code > EXPRESSION</ code > defaults to false.
8425
+ Otherwise, < code > EXPRESSION</ code > is true or false and sets exit status. </ p >
8426
+ < p > It is one of:</ p >
8427
+ < ul >
8428
+ < li > ( EXPRESSION ) < code > EXPRESSION</ code > is true</ li >
8429
+ < li > ! EXPRESSION < code > EXPRESSION</ code > is false</ li >
8430
+ < li > EXPRESSION1 -a EXPRESSION2 both < code > EXPRESSION1</ code > and < code > EXPRESSION2</ code > are true</ li >
8431
+ < li > EXPRESSION1 -o EXPRESSION2 either < code > EXPRESSION1</ code > or < code > EXPRESSION2</ code > is true</ li >
8432
+ </ ul >
8433
+ < p > String operations:</ p >
8434
+ < ul >
8435
+ < li > -n STRING the length of < code > STRING</ code > is nonzero</ li >
8436
+ < li > STRING equivalent to -n < code > STRING</ code > </ li >
8437
+ < li > -z STRING the length of < code > STRING</ code > is zero</ li >
8438
+ < li > STRING1 = STRING2 the strings are equal</ li >
8439
+ < li > STRING1 != STRING2 the strings are not equal</ li >
8440
+ </ ul >
8441
+ < p > Integer comparisons:</ p >
8442
+ < ul >
8443
+ < li > INTEGER1 -eq INTEGER2 < code > INTEGER1</ code > is equal to < code > INTEGER2</ code > </ li >
8444
+ < li > INTEGER1 -ge INTEGER2 < code > INTEGER1</ code > is greater than or equal to < code > INTEGER2</ code > </ li >
8445
+ < li > INTEGER1 -gt INTEGER2 < code > INTEGER1</ code > is greater than < code > INTEGER2</ code > </ li >
8446
+ < li > INTEGER1 -le INTEGER2 < code > INTEGER1</ code > is less than or equal to < code > INTEGER2</ code > </ li >
8447
+ < li > INTEGER1 -lt INTEGER2 < code > INTEGER1</ code > is less than < code > INTEGER2</ code > </ li >
8448
+ < li > INTEGER1 -ne INTEGER2 < code > INTEGER1</ code > is not equal to < code > INTEGER2</ code > </ li >
8449
+ </ ul >
8450
+ < p > File operations:</ p >
8451
+ < ul >
8452
+ < li >
8453
+ < p > FILE1 -ef FILE2 < code > FILE1</ code > and < code > FILE2</ code > have the same device and inode numbers</ p >
8454
+ </ li >
8455
+ < li >
8456
+ < p > FILE1 -nt FILE2 < code > FILE1</ code > is newer (modification date) than < code > FILE2</ code > </ p >
8457
+ </ li >
8458
+ < li >
8459
+ < p > FILE1 -ot FILE2 < code > FILE1</ code > is older than < code > FILE2</ code > </ p >
8460
+ </ li >
8461
+ < li >
8462
+ < p > -b FILE < code > FILE</ code > exists and is block special</ p >
8463
+ </ li >
8464
+ < li >
8465
+ < p > -c FILE < code > FILE</ code > exists and is character special</ p >
8466
+ </ li >
8467
+ < li >
8468
+ < p > -d FILE < code > FILE</ code > exists and is a directory</ p >
8469
+ </ li >
8470
+ < li >
8471
+ < p > -e FILE < code > FILE</ code > exists</ p >
8472
+ </ li >
8473
+ < li >
8474
+ < p > -f FILE < code > FILE</ code > exists and is a regular file</ p >
8475
+ </ li >
8476
+ < li >
8477
+ < p > -g FILE < code > FILE</ code > exists and is set-group-ID</ p >
8478
+ </ li >
8479
+ < li >
8480
+ < p > -G FILE < code > FILE</ code > exists and is owned by the effective group ID</ p >
8481
+ </ li >
8482
+ < li >
8483
+ < p > -h FILE < code > FILE</ code > exists and is a symbolic link (same as -L)</ p >
8484
+ </ li >
8485
+ < li >
8486
+ < p > -k FILE < code > FILE</ code > exists and has its sticky bit set</ p >
8487
+ </ li >
8488
+ < li >
8489
+ < p > -L FILE < code > FILE</ code > exists and is a symbolic link (same as -h)</ p >
8490
+ </ li >
8491
+ < li >
8492
+ < p > -N FILE < code > FILE</ code > exists and has been modified since it was last read</ p >
8493
+ </ li >
8494
+ < li >
8495
+ < p > -O FILE < code > FILE</ code > exists and is owned by the effective user ID</ p >
8496
+ </ li >
8497
+ < li >
8498
+ < p > -p FILE < code > FILE</ code > exists and is a named pipe</ p >
8499
+ </ li >
8500
+ < li >
8501
+ < p > -r FILE < code > FILE</ code > exists and read permission is granted</ p >
8502
+ </ li >
8503
+ < li >
8504
+ < p > -s FILE < code > FILE</ code > exists and has a size greater than zero</ p >
8505
+ </ li >
8506
+ < li >
8507
+ < p > -S FILE < code > FILE</ code > exists and is a socket</ p >
8508
+ </ li >
8509
+ < li >
8510
+ < p > -t FD < code > file</ code > descriptor < code > FD</ code > is opened on a terminal</ p >
8511
+ </ li >
8512
+ < li >
8513
+ < p > -u FILE < code > FILE</ code > exists and its set-user-ID bit is set</ p >
8514
+ </ li >
8515
+ < li >
8516
+ < p > -w FILE < code > FILE</ code > exists and write permission is granted</ p >
8517
+ </ li >
8518
+ < li >
8519
+ < p > -x FILE < code > FILE</ code > exists and execute (or search) permission is granted</ p >
8520
+ </ li >
8521
+ </ ul >
8522
+ < p > Except for < code > -h</ code > and < code > -L</ code > , all FILE-related tests dereference (follow) symbolic links.
8523
+ Beware that parentheses need to be escaped (e.g., by backslashes) for shells.
8524
+ < code > INTEGER</ code > may also be -l < code > STRING</ code > , which evaluates to the length of < code > STRING</ code > .</ p >
8525
+ < p > NOTE: Binary < code > -a</ code > and < code > -o</ code > are inherently ambiguous.
8526
+ Use < code > test EXPR1 && test EXPR2</ code > or < code > test EXPR1 || test EXPR2</ code > instead.</ p >
8527
+ < p > NOTE: < code > [</ code > honors the < code > --help</ code > and < code > --version</ code > options, but test does not.
8528
+ test treats each of those as it treats any other nonempty < code > STRING</ code > .</ p >
8529
+ < p > NOTE: your shell may have its own version of < code > test</ code > and/or < code > [</ code > , which usually supersedes the version described here.
8530
+ Please refer to your shell's documentation for details about the options it supports.</ p >
8416
8531
< h2 id ="examples-89 "> < a class ="header " href ="#examples-89 "> Examples</ a > </ h2 >
8417
8532
< p > Test if a given variable is equal to a given string:</ p >
8418
8533
< pre > < code class ="language-shell "> test "{{$MY_VAR}}" == "{{/bin/zsh}}"
0 commit comments