From ba003e8f20606f008c306992bea489b7f58ba1e9 Mon Sep 17 00:00:00 2001 From: Patrick Kloepfer Date: Fri, 12 Apr 2019 10:53:00 -0400 Subject: [PATCH] Updated WHILETEST and Shell Dev doc to use the newly discovered ![] (NOT Exp) logic. Put examples of usage in doc. --- .Docs/Shell Developers Guide.md | 33 +++++++++++++++++++++++++++++++-- TESTS/WHILETEST.txt | 7 +++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.Docs/Shell Developers Guide.md b/.Docs/Shell Developers Guide.md index 7fa8d905..2a31d20e 100644 --- a/.Docs/Shell Developers Guide.md +++ b/.Docs/Shell Developers Guide.md @@ -52,6 +52,35 @@ IFTTT Tweet using HTTPGET where [ exp ] and [ condition ] allow to detail operators.... +anywhere you can have [ exp ] you can have ![ exp ] which means NOT exp. + + + while ![ $total -eq 0 ] + loop + +is the same thing as + + while [ $total -ne 0 ] + loop + +Just like + + IF [ A -GT 5 ] + DO X + ELSE + DO Y + FI + +is the same as + + IF ![ A -LE 5 ] + DO Y + ELSE + DO X + FI + +Notice that the DO X and DO Y logic is swapped between the two cases. + ## Internal Shell commands: | Name | Status | Comment | @@ -59,7 +88,7 @@ where [ exp ] and [ condition ] allow to detail operators.... | \ | Working | $VAR \| string \| "string with SPACE" \| 123 \| -456 | | \ | Working | \ [\ \] ... | | \ | Working | \+ signed int32 add
\- signed int32 sub
\*
/
mod | -| \ | Working |[ -D direxists ]
[ -E fileordirexists ]
[ -F fileexists ]
[ -N $VAR variable is not empty ]
[ -Z $VAR variable is empty ]
[ string1 = string2 ]
[ string1 != string2 ]
[ string1 .< string2 ]
[ string1 <= string2 ]
[ string1 .> string2 ]
[ string1 >= string2 ]
[ int32 -eq int32 ]
[ int32 -ne int32 ]
[ int32 -lt int32 ]
[ int32 -le int32 ]
[ int32 -gt int32 ]
[ int32 -ge int32 ] | +| \ | Working |[ -D direxists ]
[ -E fileordirexists ]
[ -F fileexists ]
[ -N $VAR variable is not empty ]
[ -Z $VAR variable is empty ]
[ string1 = string2 ]
[ string1 != string2 ]
[ string1 .< string2 ]
[ string1 <= string2 ]
[ string1 .> string2 ]
[ string1 >= string2 ]
[ int32 -eq int32 ]
[ int32 -ne int32 ]
[ int32 -lt int32 ]
[ int32 -le int32 ]
[ int32 -gt int32 ]
[ int32 -ge int32 ]| | BREAK | Working | Exit CASE of SWITCH | | CALL | Working | CALL function ... | | CASE | Working | CASE | @@ -73,7 +102,7 @@ where [ exp ] and [ condition ] allow to detail operators.... | EXIT | Working | exit function, script or shell | | FI | Working | Terminator for IF block | | FUNC | In Progress | FUNC fonction_name
\
END | -| IF | Working | [ \ ] | +| IF | Working | [ \ ]
![ \ ]| | LOOP | Working | Terminator for WHILE block | | MD | Working | MD path or relative path
Create a directory | | NOHUP | Working | Start a process with PPID=PS0 (Daemon) | diff --git a/TESTS/WHILETEST.txt b/TESTS/WHILETEST.txt index 03ac2656..2773079a 100644 --- a/TESTS/WHILETEST.txt +++ b/TESTS/WHILETEST.txt @@ -59,12 +59,15 @@ ELSE ECHO "WHILE LOOP Test 2 Failed" >> ${Log} FI FI +# +# This next tests uses the NOT variant of the condition block +# set counter = 0 set total = 2000 -while [ $total -ne 0 ] +while ![ $total -eq 0 ] set total = $total - 100 set counter = $counter + 1 - ECHO -N "\e[18;10HTest 3 - Counter : ${count} Total : ${total}" + ECHO -N "\e[18;10HTest 3 - Counter : ${count} Total : ${total} " loop IF [ $counter -eq 20 ] IF [ -N $Log ]