From 904a41293096723b90e9e6c0b091f89f56c55a2e Mon Sep 17 00:00:00 2001 From: BrainwreckedTech <3752022+BrainwreckedTech@users.noreply.github.com> Date: Mon, 20 Dec 2021 01:00:11 -0500 Subject: [PATCH] Allow `partvis` to take stdin --- partvis | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/partvis b/partvis index d38345d..f678941 100755 --- a/partvis +++ b/partvis @@ -20,9 +20,11 @@ sectors_to_size() { [ $EUID -gt 0 ] && echo "Must run as superuser." && exit 1 -for DEVICE in $(fdisk -l | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 | cut -d: -f1); do +[ -t 0 ] && DEVLIST="$(fdisk -l)" || DEVLIST="$(cat -)" - FDISKDATA="$(fdisk -l "${DEVICE}")" +for DEVICE in $(echo "${DEVLIST}" | grep '^Disk /' | grep -v '/dev/ram' | cut -d\ -f2 | cut -d: -f1); do + + [ -t 0 ] && FDISKDATA="$(fdisk -l "${DEVICE}")" || FDISKDATA="${DEVLIST}" COLS="$(tput cols)" SECTORS="$(echo "${FDISKDATA}" | grep sectors | grep -v 'sectors of' | rev | cut -d\ -f2 | rev)" #PARTLIST="$(echo "${FDISKDATA}" | grep '^/' | sed 's/ */ /g' | cut -d\ -f1-3)"