some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2024-03-06 09:39:50 +03:00
parent c586c36877
commit 97de482afa

View File

@ -127,22 +127,30 @@ while true ; do
if [[ $INTERACTIVE || ! $DRIVE ]] ; then if [[ $INTERACTIVE || ! $DRIVE ]] ; then
INTERACTIVE=1 INTERACTIVE=1
echo "Select/toggle an option:" echo "Select/toggle an option:"
echo "0) Multi flash card mode is `[[ $MULTI ]] && echo "on" || echo "off"`" if [ -z $MULTI_STARTED ] ; then
echo "1) Directoy description is: \"$TITLE\"." if [[ $MULTI ]] ; then
echo "0) Multiple flash cards"
else
echo "0) Single flash card"
fi
else
echo "0) Build after this flash card: `[[ $LAST ]] && echo "yes" || echo "no"`"
fi
echo "1) Directoy description is: \"$TITLE\""
if [[ ! $DRIVE ]] ; then if [[ ! $DRIVE ]] ; then
echo "a-z|name) Type a drive letter, mount name in $BASE or path and start." echo "a-z|name) Type a drive letter, mount name in $BASE or path and start"
echo " (paths must start with \"/\", \"./\" or \"[A-Z]:\")" echo " (paths must start with \"/\", \"./\" or \"[A-Z]:\")"
else else
echo "a-z|name) Type a drive letter, mount name in $BASE or path and start." echo "a-z|name) Type a drive letter, mount name in $BASE or path and start"
echo " (paths must start with \"/\", \"./\" or \"[A-Z]:\")" echo " (paths must start with \"/\", \"./\" or \"[A-Z]:\")"
echo "Enter) Copy drive ${DRIVE}" echo "Enter) Copy drive ${DRIVE}"
fi fi
echo "2) Build." echo "2) Build"
if ! [ -z $COMPRESSOR ] ; then if ! [ -z $COMPRESSOR ] ; then
echo "3) Compresion is `[[ $COMPRESS ]] && echo "on" || echo "off"`" echo "3) Compresion is `[[ $COMPRESS ]] && echo "on" || echo "off"`"
echo "4) Quit." echo "4) Quit"
else else
echo "3) Quit." echo "3) Quit"
fi fi
read -ep ": " RES read -ep ": " RES
@ -151,7 +159,11 @@ while true ; do
case $RES in case $RES in
# toggle multi mode... # toggle multi mode...
0) 0)
if [ -z $MULTI_STARTED ] ; then
MULTI=`[[ ! $MULTI ]] && echo 1 || echo ""` MULTI=`[[ ! $MULTI ]] && echo 1 || echo ""`
else
LAST=`[[ ! $LAST ]] && echo 1 || echo ""`
fi
continue continue
;; ;;
1) 1)
@ -186,18 +198,19 @@ while true ; do
# new drive letter... # new drive letter...
*) *)
# explicit path given...
if [[ "${RES::1}" == "/" ]] \
|| [[ "${RES::2}" == "./" ]] \
|| [[ "${RES::2}" =~ [a-zA-Z]: ]] \
&& [ -e "$RES" ] ; then
BASE=
fi
DRIVE=$RES DRIVE=$RES
;; ;;
esac esac
fi fi
# explicit path given...
if [[ "${DRIVE::1}" == "/" ]] \
|| [[ "${DRIVE::2}" == "./" ]] \
|| [[ "${DRIVE::2}" =~ [a-zA-Z]: ]] \
&& [ -e "$DRIVE" ] ; then
BASE=
fi
# sanity check... # sanity check...
if ! [ -e "${BASE}${DRIVE}" ] ; then if ! [ -e "${BASE}${DRIVE}" ] ; then
echo echo
@ -225,12 +238,16 @@ while true ; do
else else
BASE_DIR="${DATE}${TITLE}/" BASE_DIR="${DATE}${TITLE}/"
DIR="${BASE_DIR}/${DATE}.${SCOUNT}" DIR="${BASE_DIR}/${DATE}.${SCOUNT}"
# get next dir index...
while [ -e *"$DIR"* ] ; do while [ -e *"$DIR"* ] ; do
COUNT=$((COUNT+1)) COUNT=$((COUNT+1))
SCOUNT=`printf "%03d" $COUNT` SCOUNT=`printf "%03d" $COUNT`
DIR="${BASE_DIR}/${DATE}.${SCOUNT}" DIR="${BASE_DIR}/${DATE}.${SCOUNT}"
done done
fi fi
MULTI_STARTED=1
# normalize paths... # normalize paths...
BASE_DIR="./- ${BASE_DIR}/" BASE_DIR="./- ${BASE_DIR}/"
DIR="./- $DIR/" DIR="./- $DIR/"