From aba50c2843e745a9e2b1c5e8483951543069dc4b Mon Sep 17 00:00:00 2001 From: emma Date: Tue, 16 Jan 2024 12:52:26 -0700 Subject: [PATCH] formatting, quoting, & typo --- build-index.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/build-index.sh b/build-index.sh index 35c5ec1..41c30d7 100755 --- a/build-index.sh +++ b/build-index.sh @@ -1,9 +1,9 @@ #!/bin/sh -# defin the target dir -parent=$(dirname "${BASH_SOURCE[0]}") -cd $parent; cd ../../../ -directory=$(pwd -P) +# define the target dir +parent="$(dirname "${BASH_SOURCE[0]}")" +cd "$parent"; cd ../../../ +directory="$(pwd -P)" today="$(date "+%Y-%m-%d")" @@ -11,25 +11,30 @@ printf "Date: %s\n" "$today" for dirs in "$directory"/*; do string="$(printf "---\n")" - area=$(basename "${dirs}") + area="$(basename "${dirs}")" if [ "$area" != "System Volume Information" ]; then string="$(printf "%stitle: %s\n" "$string" "$area")" string="$(printf "%sdate: %s\n" "$string" "$today")" string="$(printf "%s---\n\n" "$string")" + for cats in "$dirs"/*; do - category=$(basename "${cats}") + category="$(basename "$cats")" string="$(printf "%s# %s\n\n" "$string" "$category")" + for ids in "$cats"/*; do - ident=$(basename "${ids}") + ident="$(basename "$ids")" string="$(printf "%s* %s\n" "$string" "$ident")" done + string="$(printf "%s\n" "$string")" done - savedir="$directory/00-09 Index/00 Index/00.01 Index/" - fname="${area:0:5}.md" - fullpath="$savedir$fname" - printf '%s\n' "$fullpath" - printf '%s' "$string" > "$fullpath" + + savedir="$directory/00-09 Index/00 Index/00.01 Index/" + fname="${area:0:5}.md" + fullpath="$savedir$fname" + + printf '%s\n' "$fullpath" + printf '%s' "$string" > "$fullpath" fi done