Skip to content

Commit

Permalink
Issue #16: Add better expand directory options
Browse files Browse the repository at this point in the history
  • Loading branch information
ckardaris committed Sep 19, 2021
1 parent 38daa93 commit 0a6003a
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions src/filelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,45 @@ read_filenames() {
done
elif [[ "$expand_dirs" == "ask" ]]
then
local yesall=0
local first_item=1
for item in "${filelist[@]}"
do
[[ -d "$item" ]] \
&& read -p "Expand $item? (n, Esc: no, N: no to all)" -rsN1 char \
&& echo
[[ "$char" == "N" ]] && break
[[ ! "$char" =~ ^(n|$'\e')$ ]] && filelist+=("$item"/*)
if [[ -d "$item" ]]
then
if [[ "$yesall" -eq 1 ]]
then
filelist+=("$item"/*)
else
[[ "$first_item" -eq 1 ]] \
&& printf "Expand directory options:\n" \
&& printf " y/Enter\tyes\n" \
&& printf " Y\t\tyes to all\n" \
&& printf " n\t\tno\n" \
&& printf " N\t\tno to all\n" \
&& printf "%s\n" "------------------------" \
&& first_item=0
read -p "Expand $item? " -rsN1 char
case "$char" in
"N")
echo N
break
;;
"Y")
echo Y
filelist+=("$item"/*)
yesall=1
;;
"y"|$'\n')
echo y
filelist+=("$item"/*)
;;
*)
echo n
;;
esac
fi
fi
done
fi
argc="${#filelist[@]}"
Expand Down

0 comments on commit 0a6003a

Please sign in to comment.