rwx/sh/util.sh

51 lines
692 B
Bash
Raw Normal View History

2025-06-28 04:36:16 +02:00
# ╭──────╮
# │ util │
# ╰──────╯
2025-07-27 19:06:50 +02:00
# TODO awk
rwx_not() {
case "${1}" in
"false") echo "true" ;;
"true") echo "false" ;;
*) ;;
esac
}
rwx_read_passphrase() {
rwx_read_secret "PassPhrase: "
}
2025-07-27 17:30:07 +02:00
#| stty
rwx_read_secret() {
local prompt="${1}"
local secret
printf "%s" "${prompt}" 1>&2
stty -echo
read -r secret
stty echo
echo >&2
echo "${secret}"
unset secret
}
rwx_remove() {
rm \
--force \
--recursive \
"${@}"
}
2025-07-02 15:16:21 +02:00
rwx_root() {
2025-07-03 21:45:15 +02:00
local user_id
user_id="$(id --user)"
2025-07-03 22:18:02 +02:00
[ "${user_id}" -eq 0 ] || return 1
2025-07-02 15:16:21 +02:00
}
rwx_warn_wipe() {
local tmp
2025-07-27 19:06:50 +02:00
rwx_list_block
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
read -r tmp
rwx_log_trace "${tmp}"
}