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)"