mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 00:26:16 +03:00
compute pow() with shell only, in case we don't have bc, dc, perl
This commit is contained in:
@@ -40,9 +40,21 @@ fakedate()
|
||||
fakecmd "$1" date +$fmt
|
||||
}
|
||||
|
||||
#
|
||||
# compute x**n.
|
||||
# use only the shell, in case we need to run on machines
|
||||
# without bc, dc, perl, etc.
|
||||
#
|
||||
pow()
|
||||
{
|
||||
dc -e "$1 $2 ^ p"
|
||||
typeset x="$1" n="$2"
|
||||
typeset r=1
|
||||
typeset i=0
|
||||
while ((i < n)); do
|
||||
((r = r*x))
|
||||
((i++))
|
||||
done
|
||||
echo $r
|
||||
}
|
||||
|
||||
# run a fakedate test with a given time t
|
||||
|
||||
Reference in New Issue
Block a user