mirror of
https://github.com/notwa/rc
synced 2024-12-21 21:49:40 -08:00
22 lines
670 B
Bash
Executable file
22 lines
670 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.
|
|
|
|
hex() { ### @-
|
|
### perform arithmetic using the shell and display the result as
|
|
### an unsigned 32-bit integer in hexadecimal.
|
|
### see also [`arith`](#arith) and [`bin`](#bin).
|
|
###
|
|
### ```
|
|
### $ hex 0x221EA8-0x212020
|
|
### 0000FE88
|
|
### ```
|
|
###
|
|
### **NOTE:** there also exists a hex(1) program provided by
|
|
### the *basez* package that i don't use.
|
|
printf "%08X\n" "$(($@))"
|
|
}
|
|
|
|
[ -n "${preload+-}" ] || hex "$@"
|