From 61c000d96f184388f5f42d7501895138fc328eba Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 29 Aug 2021 20:04:14 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Three=20columns=20in=20mftest=20?= =?UTF-8?q?menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/bin/mftest | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index e0c1d8f38d..17605e3174 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -206,13 +206,26 @@ fi if [[ $TESTENV == '-' ]]; then IND=0 NAMES=() + MENU=() + BIGLEN=0 for FILE in $( ls -1 $TESTPATH/* ) do let IND++ TNAME=${FILE/$TESTPATH\//} NAMES+=($TNAME) - (( IND < 10 )) && echo -n " " - echo " $IND) $TNAME" + IFS="" + ITEM=$( printf "%2i) %s" $IND $TNAME ) + MENU+=($ITEM) + [[ ${#ITEM} -gt $BIGLEN ]] && BIGLEN=${#ITEM} + done + + (( BIGLEN += 2 )) + THIRD=$(( (${#MENU[@]} + 2) / 3 )) + for ((i = 0; i < $THIRD; i++)) + do + COL1=$i ; COL2=$(( $i + $THIRD )) ; COL3=$(( $i + 2 * $THIRD )) + FMT="%-${BIGLEN}s" + printf "${FMT}${FMT}${FMT}\n" ${MENU[$COL1]} ${MENU[$COL2]} ${MENU[$COL3]} done echo