1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-20 10:53:23 -07:00
rc/sh/hex

26 lines
640 B
Bash
Executable File

#!/usr/bin/env zsh
# YES_ZSH
# YES_BASH
# YES_DASH
# YES_ASH
# 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 "$@"