1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-09 18:49:03 -08:00
rc/sh/arith

21 lines
577 B
Bash
Executable file

#!/usr/bin/env zsh
# compat: +ash +bash +dash +hush +ksh +mksh +oksh +osh +posh +yash +zsh
# though technically compatible with other shells,
# extra functionality is through zsh's extended arithmetic functions.
arith() { ### @-
### perform arithmetic using the shell and display the result.
### see also [`hex`](#hex) and [`bin`](#bin).
### this example requires zsh:
###
### ```
### % db=6
### % noglob arith 10**(db/20.)
### 1.9952623149688795
### ```
# <<<"$(($@))"
printf "%s\n" "$(($@))"
}
[ -n "${preload+-}" ] || arith "$@"