now using printf

This commit is contained in:
R. Nicolás Savinelli 2020-07-13 17:47:15 -03:00
parent 4cc6429826
commit f6956261b9
1 changed files with 2 additions and 1 deletions

3
lb
View File

@ -27,9 +27,10 @@ newpost() { read -erp "Give a title for your post:
$EDITOR "$webdir/blog/.drafts/$url.html" ;}
listandReturn() {
printf "Listing contents of %s\\n" "$1"
case "$(ls "$1" | wc -l)" in
0) echo "There's nothing to $2." && exit 1 ;;
1) number=1 && echo "There's only one entry to $2. Defaulting selection to $(ls -rc "$1" | awk -F '/' '{print $NF}')" ;;
1) number=1 && printf "There's only one blog entry to %s.\\nDefaulting selection to %s\\n" "$2" "$(ls -rc "$1" | awk -F '/' '{print $NF}')" ;;
*) ls -rc "$1" | awk -F '/' '{print $NF}' | nl
read -erp "Pick an entry by number to $2, or press Ctrl-C to cancel. " number ;;
esac