Add HDD device previews and root guards
This commit is contained in:
1 parent
33c4229848
commit
cf53a6bb50
5 files changed
+52
-16
No files matched your search
@@ -90,3 +90,24 @@ common::require_cmd() {
|
||||
common::die "required command '${cmd}' not found on PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
# common::show_block_devices prints available block devices and highlights
|
||||
# the selected device when output is going to a terminal.
|
||||
common::show_block_devices() {
|
||||
local selected_device="$1"
|
||||
local color=0
|
||||
|
||||
if [[ -t 1 && -z "${NO_COLOR:-}" ]]; then
|
||||
color=1
|
||||
fi
|
||||
|
||||
common::log "Available block devices and mount points (selected device highlighted):"
|
||||
lsblk --list --paths --output PATH,SIZE,TYPE,FSTYPE,MOUNTPOINTS \
|
||||
| awk -v selected="$selected_device" -v color="$color" '
|
||||
NR > 1 && $1 == selected && color {
|
||||
printf "\033[31m%s\033[0m\n", $0
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
'
|
||||
}
|
||||
Reference in new issue
Block a user