From cc51226f4ce23156ad328e8ffa9b335fda98be90 Mon Sep 17 00:00:00 2001 From: Ryan L McIntyre Date: Sat, 29 Oct 2016 11:09:21 -0400 Subject: [PATCH] Style and possible syntax issue fixes (linting via ShellCheck) --- standardize-and-complete-readmes.sh | 45 +++++++++-------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/standardize-and-complete-readmes.sh b/standardize-and-complete-readmes.sh index 359c7b73e..7e940d2e5 100755 --- a/standardize-and-complete-readmes.sh +++ b/standardize-and-complete-readmes.sh @@ -6,62 +6,45 @@ infofilename="font-info.md" -cd unpatched-sample-fonts/ +cd unpatched-sample-fonts/ || exit #find ./DejaVuSansMono -type d | # uncomment to test 1 font -find -type d | # uncomment to do ALL fonts -while read filename +find . -type d | # uncomment to do ALL fonts +while read -r filename do - #echo "filename $filename" - dirname=`dirname $filename` - basename=`basename $filename` - echo "dirname $dirname" - echo "basename $basename" + dirname=$(dirname "$filename") searchdir=$filename # limit looking for the readme files in the parent dir not the child dirs: if [[ $dirname != "." ]]; then - echo "look up a lvl" searchdir=$dirname fi - RST=( $(find $searchdir -type f -iname 'readme.rst' -exec basename {} \;) ) - TXT=( $(find $searchdir -type f -iname 'readme.txt' -exec basename {} \;) ) + RST=( $(find "$searchdir" -type f -iname 'readme.rst' -exec basename {} \;) ) + TXT=( $(find "$searchdir" -type f -iname 'readme.txt' -exec basename {} \;) ) outputdir=$PWD/../patched-fonts/$filename/ outputlocation=$outputdir/$infofilename [[ -d "$outputdir" ]] || mkdir -p "$outputdir" - echo "RST:" - echo $RST - echo "end" - #exit - # clear output file (needed for multiple runs or updates): - > $outputlocation + > "$outputlocation" - if [ $RST ]; + if [ "${RST[0]}" ]; then - echo "pwd/filename $PWD/$filename" echo "found RST" - pandoc "$PWD/$searchdir/$RST" --from=rst --to=markdown --output=$outputlocation - #echo "pandoc $PWD/$filename/$RST --from=rst --to=markdown --output=$outputlocation" - #echo "pwd $PWD" - cat $PWD/../source/readme-per-directory-addendum.md >> $outputlocation - elif [ $TXT ]; + pandoc "$PWD/$searchdir/${RST[0]}" --from=rst --to=markdown --output="$outputlocation" + cat "$PWD/../source/readme-per-directory-addendum.md" >> "$outputlocation" + elif [ "${TXT[0]}" ]; then - echo "pwd/filename $PWD/$searchdir" echo "found TXT" echo "nothing to do for conversion, just copy as markdown" - cp $PWD/$searchdir/$TXT $outputlocation - #echo "pwd $PWD" - cat $PWD/../source/readme-per-directory-addendum.md >> $outputlocation + cp "$PWD/$searchdir/${TXT[0]}" "$outputlocation" + cat "$PWD/../source/readme-per-directory-addendum.md" >> "$outputlocation" else - echo "pwd/filename $PWD/$searchdir" - # else doesnt copy parent dir. somehow do this... echo "did not find RST nor TXT" - cat $PWD/../source/readme-per-directory-addendum.md >> $outputlocation + cat "$PWD/../source/readme-per-directory-addendum.md" >> "$outputlocation" fi done