diff options
author | Leah Rowe <leah@libreboot.org> | 2025-10-04 09:14:33 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-10-04 09:20:12 +0100 |
commit | e9a910b33c7837b4b868e3abda18eb4810df7f02 (patch) | |
tree | 749e1830cb0607952df1a1afc0ae09ec1db54140 /util/sbase/expr.1 | |
parent | 2cfaba181b3c68761871fa47b32725c934423c14 (diff) |
config/git: import suckless sbase
i currently use the output of sha512sum in several
places of xbmk, which is a bit unreliable in case
output changes.
other cases where i use util outputs in variables
are probably reliable, because i'm using mostly
posix utilities in those.
to mitigate this, i now import suckless sbase, which
has a reasonable sha512sum implementation.
*every* binary it builds is being placed in build.list,
because i'll probably start using more of them.
for example, i may start modifying the "date"
implementation, adding the GNU-specific options that
i need as mentioned on init.sh
i'm importing it in util/ because the sha512sum
util is needed for verifying project sources, so
if sbase itself is a "project source", that means
we can into a chicken and egg bootstrapping problem.
this is sbase at revision:
055cc1ae1b3a13c3d8f25af0a4a3316590efcd48
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/sbase/expr.1')
-rw-r--r-- | util/sbase/expr.1 | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/util/sbase/expr.1 b/util/sbase/expr.1 new file mode 100644 index 00000000..4710fc40 --- /dev/null +++ b/util/sbase/expr.1 @@ -0,0 +1,101 @@ +.Dd October 8, 2015 +.Dt EXPR 1 +.Os sbase +.Sh NAME +.Nm expr +.Nd evaluate expression +.Sh SYNOPSIS +.Nm +.Ar expression +.Sh DESCRIPTION +.Nm +evaluates +.Ar expression +and writes the result to stdout. +.Pp +There are two elemental expressions, +.Sy integer +and +.Sy string . +Let +.Sy expr +be a non-elemental expression and +.Sy expr1 , +.Sy expr2 +arbitrary expressions. +Then +.Sy expr +has the recursive form +.Sy expr = [(] expr1 operand expr2 [)] . +.Pp +With +.Sy operand +being in order of increasing precedence: +.Bl -tag -width Ds +.It | +Evaluate to +.Sy expr1 +if it is neither an empty string nor 0; otherwise evaluate to +.Sy expr2 . +.It & +Evaluate to +.Sy expr1 +if +.Sy expr1 +and +.Sy expr2 +are neither empty strings nor 0; otherwise evaluate to 0. +.It = > >= < <= != +If +.Sy expr1 +and +.Sy expr2 +are integers, evaluate to 1 if the relation is true and 0 if it is false. +If +.Sy expr1 +and +.Sy expr2 +are strings, apply the relation to the return value of +.Xr strcmp 3 . +.It + - +If +.Sy expr1 +and +.Sy expr2 +are integers, evaluate to their sum or subtraction. +.It * / % +If +.Sy expr1 +and +.Sy expr2 +are integers, evaluate to their multiplication, division or remainder. +.It : +Evaluate to the number of characters matched in +.Sy expr1 +against +.Sy expr2 . expr2 +is anchored with an implicit '^'. +.Pp +You can't directly match the empty string, since zero matched characters +resolve equally to a failed match. +To work around this limitation, use "expr X'' : 'X$' instead of "expr '' +: '$'" +.El +.Sh EXIT STATUS +.Bl -tag -width Ds +.It 0 +.Ar expression +is neither an empty string nor 0. +.It 1 +.Ar expression +is an empty string or 0. +.It 2 +.Ar expression +is invalid. +.It > 2 +An error occurred. +.El +.Sh SEE ALSO +.Xr test 1 +.Sh STANDARDS +POSIX.1-2013. |