From 23564c7159add3dbf84f4d74de3108c63472034d Mon Sep 17 00:00:00 2001 From: "[GPL]Ed" Date: Fri, 1 Dec 2023 18:02:45 +0000 Subject: [PATCH] Modify docs --- doc/man1/expr.1 | 23 ++++++++--------------- doc/man1/zrc.1 | 2 +- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/doc/man1/expr.1 b/doc/man1/expr.1 index 3229d90..634fb0b 100644 --- a/doc/man1/expr.1 +++ b/doc/man1/expr.1 @@ -2,13 +2,15 @@ .SH NAME expr \- Evaluate expressions .SH SYNOPSIS -.BI "expr [" -r "] [" EXPRESSION ] +.BI "expr [" EXPRESSION ] .SH DESCRIPTION This builtin concatenates all of its arguments into one arithmetic expression, evaluates it and returns its value. All of these functions/operators can also be found in other languages, such as C or Python. Remember to escape certain symbols when necessary, so they don't conflict with Zrc constructs (globbing, tilde expansion, redirection, etc.) .PP Note that this command actually returns a value, as opposted to POSIX .I expr -which writes to stdout, so square brackets should be used to access it. +which writes to stdout, so square brackets should be used to access it. NOTE that the interpreter obviously has no idea if you want to bit shift or redirect, so if you use bit manipulation operators, remember to +.I brace your expr-essions +to not clobber files. (and other obvious reasons, like double substitution. See the Tcler's Wiki, it all applies to Zrc too :-) ) .SS Precedence level 0 .RB ( , ) ; .SS Precedence level 1 (ternary operator) @@ -34,31 +36,22 @@ which writes to stdout, so square brackets should be used to access it. .SS Precedence level 11 .RB + , - ; .SS Precedence level 12 -.RB * , / , // , % ; +.RB * , / , ** , // , % ; .SS Precedence level 13: implicit .SS Functions .RB log10 , log2 , ln / log , sqrt , sin , asin / arcsin , cos , acos / arccos , ctg / cot , actg / acot / arcctg / arccot , tg / tan , atg / atan / arctg / arctan , sec , arcsec / asec , csc / cosec , acsc / acosec / arccsc / arccosec / floor , ceil , abs , round , trunc; .SS Other words .RB nan , false , true ; .SS Unary operators -.RB - , + , ~ . -.SH OPTIONS -.TP -.BR r -Evaluate args as a -.B reverse polish notation -expression (RPN), instead of an -.B infix notation -expression. NOTE that in this mode, whitespace is required, so if you use bit manipulation operators, remember to -.I brace your expr-essions -to not clobber files. (and other obvious reasons, like double substitution. See the Tcler's Wiki, it all applies to Zrc too :-) ) +.RB - , + , ~ , ! . .SH EXAMPLES .EX echo [expr 1+2/(100**3+log(4))//2+sin 2+cos(floor(ceil(-8.7)))] echo [expr 1&&2||(1?2:0)+5&(3<<1)] echo [expr 1 + 2/ 3 + 4] - # RPN expressions used to be supported, but now they have been removed. + # RPN expressions used to be supported, but now they have been removed due to a new reimplementation using a proper BNF. + # They may return in a future version, but the standard mathop.zrc already provides similar functionality... echo [expr -r {1 2 + 3 '*' 2 '<<'}] echo [expr {((1+2)*3)<<2}] diff --git a/doc/man1/zrc.1 b/doc/man1/zrc.1 index ab17e7a..5ecceb3 100644 --- a/doc/man1/zrc.1 +++ b/doc/man1/zrc.1 @@ -363,7 +363,7 @@ Replace the current shell process. .br Exit Zrc. .HP -.BI "expr [" -r "] [" EXPRESSION ] +.BI "expr [" EXPRESSION ] .br Evaluate arithmetic expressions. .HP