alexmyczko / fnt

apt for fonts, the missing font manager for macOS/linux
Other
489 stars 20 forks source link

shellcheck #3

Closed alexmyczko closed 3 years ago

alexmyczko commented 3 years ago
In fnt line 29:
        echo Please report $s to https://github.com/alexmyczko/fnt/issues
                                   ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        echo Please report "$s" to https://github.com/alexmyczko/fnt/issues

In fnt line 35:
    which $a >/dev/null
    ^---^ SC2230: which is non-standard. Use builtin 'command -v' instead.
          ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
    which "$a" >/dev/null

In fnt line 36:
    if [ ! $? -eq 0 ]; then
           ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

In fnt line 37:
        echo $a not found, please use $i to install it.
             ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        echo "$a" not found, please use $i to install it.

In fnt line 42:
if [ ${1}x == x ]; then
     ^--^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
if [ "${1}"x == x ]; then

In fnt line 52:
        if [ ! -d ${TMPDIR} ]; then mkdir -p ${TMPDIR}; fi
                          ^-------^ SC2086: Double quote to prevent globbing and word splitting.
                                                     ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        if [ ! -d "${TMPDIR}" ]; then mkdir -p "${TMPDIR}"; fi

In fnt line 53:
            if [ -f ${TMPDIR}/Packages.xz ]; then rm ${TMPDIR}/Packages.xz; fi
                        ^-------^ SC2086: Double quote to prevent globbing and word splitting.
                                                         ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
            if [ -f "${TMPDIR}"/Packages.xz ]; then rm "${TMPDIR}"/Packages.xz; fi

In fnt line 54:
            curl -s $INDEX -o ${TMPDIR}/Packages.xz
                                  ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
            curl -s $INDEX -o "${TMPDIR}"/Packages.xz

In fnt line 61:
        ls -1 $HOME/Library/Fonts/*.?tf $HOME/.fonts/*.?tf 2>/dev/null | while read f; do
                ^-- SC2012: Use find instead of ls to better handle non-alphanumeric filenames.
                      ^---^ SC2086: Double quote to prevent globbing and word splitting.
                                                ^---^ SC2086: Double quote to prevent globbing and word splitting.
                                                                                       ^--^ SC2162: read without -r will mangle backslashes.

Did you mean: 
        ls -1 "$HOME"/Library/Fonts/*.?tf "$HOME"/.fonts/*.?tf 2>/dev/null | while read f; do

In fnt line 62:
            echo "$f [$(otfinfo -u ""$f"" 2>/dev/null|wc -l)]" | sed s,.*/,,
                                                 ^-- SC2027: The surrounding quotes actually unquote this. Remove or escape them.
                                                 ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
            echo "$f [$(otfinfo -u """$f""" 2>/dev/null|wc -l)]" | sed s,.*/,,

In fnt line 68:
        img=$(lynx -dump https://screenshots.debian.net/package/fonts-$2 | grep large.png | sed s,.*http,http,)
                                                                              ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        img=$(lynx -dump https://screenshots.debian.net/package/fonts-"$2" | grep large.png | sed s,.*http,http,)

In fnt line 70:
        curl -s $img -o ${TMPDIR}/preview.png
                        ^--^ SC2086: Double quote to prevent globbing and word splitting.
                                ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        curl -s "$img" -o "${TMPDIR}"/preview.png

In fnt line 71:
        chafa --invert -c none --symbols block+border-solid ${TMPDIR}/preview.png
                                                                    ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        chafa --invert -c none --symbols block+border-solid "${TMPDIR}"/preview.png

In fnt line 77:
        p=$(cat $HOME/.fnt/Packages.xz |unxz| grep -v "^Architecture:\|^Section:\|^Priority:\|^Replaces:\|^Provides:\|^Brekas:\|^Maintainer:\|^MD5sum:\|^Source:\|^Breaks:\|^Multi-Arch:\|^Description-\|^Tag:\|^SHA256:"|awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-"|grep fonts-$2|head -1)
                        ^---^ SC2086: Double quote to prevent globbing and word splitting.
                        ^--------------------^ SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
                                                                                                                                                                                                                                                                                                                      ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        p=$(cat "$HOME"/.fnt/Packages.xz |unxz| grep -v "^Architecture:\|^Section:\|^Priority:\|^Replaces:\|^Provides:\|^Brekas:\|^Maintainer:\|^MD5sum:\|^Source:\|^Breaks:\|^Multi-Arch:\|^Description-\|^Tag:\|^SHA256:"|awk '!NF{print line; line=""}{line=line " " $0}' |grep "Package: fonts-"|grep fonts-"$2"|head -1)

In fnt line 79:
        name=$(echo $p | awk '{print $2}')
                            ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        name=$(echo "$p" | awk '{print $2}')

In fnt line 80:
        ver=$(echo $p | awk '{print $4}')
                           ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        ver=$(echo "$p" | awk '{print $4}')

In fnt line 81:
        instsize=$(echo $p | awk '{print $6}')
                                ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        instsize=$(echo "$p" | awk '{print $6}')

In fnt line 82:
        downsize=$(echo $p | awk '{print $NF}')
                                ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        downsize=$(echo "$p" | awk '{print $NF}')

In fnt line 83:
        url=$(echo $p | awk '{print $(NF-2)}')
                           ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        url=$(echo "$p" | awk '{print $(NF-2)}')

In fnt line 84:
        f=$(basename $url)
                             ^--^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        f=$(basename "$url")

In fnt line 86:
        curl -s ${MIRROR}${url} -o ${TMPDIR}/$f
                                 ^----^ SC2086: Double quote to prevent globbing and word splitting.
                                           ^-------^ SC2086: Double quote to prevent globbing and word splitting.
                                                     ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        curl -s ${MIRROR}"${url}" -o "${TMPDIR}"/"$f"

In fnt line 87:
        cd ${TMPDIR}
                ^----------^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
                   ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        cd "${TMPDIR}" || exit

In fnt line 88:
        ar x $f
                     ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        ar x "$f"

In fnt line 90:
        find ${TMPDIR} . -name "*.?tf" -exec cp {} $target \;
                     ^-------^ SC2086: Double quote to prevent globbing and word splitting.
                                                           ^-----^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        find "${TMPDIR}" . -name "*.?tf" -exec cp {} "$target" \;

In fnt line 91:
        rm $f control.tar* data.tar* debian-binary
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        rm "$f" control.tar* data.tar* debian-binary

In fnt line 92:
        rm -rf ${TMPDIR}/usr
                       ^-----------^ SC2115: Use "${var:?}" to ensure this never expands to /usr .
                       ^-------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
        rm -rf "${TMPDIR}"/usr

In fnt line 101:
        cat $HOME/.fnt/Packages.xz |unxz |grep ^Package:\ fonts-|awk '{print $2}' | grep "$2"
                    ^---^ SC2086: Double quote to prevent globbing and word splitting.
                    ^--------------------^ SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

Did you mean: 
        cat "$HOME"/.fnt/Packages.xz |unxz |grep ^Package:\ fonts-|awk '{print $2}' | grep "$2"

For more information:
  https://www.shellcheck.net/wiki/SC2027 -- The surrounding quotes actually u...
  https://www.shellcheck.net/wiki/SC2115 -- Use "${var:?}" to ensure this nev...
  https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |...
jo1gi commented 3 years ago

Do you want these warnings fixed? I would be happy to help.

alexmyczko commented 3 years ago

The problem I want to fix atm is it fails with font filenames with spaces in it. HALP!!1

jo1gi commented 3 years ago

@alexmyczko Do you have an example?

alexmyczko commented 3 years ago

yes,fnt install courier-prime it would install, but fnt list would list the fonts without [glyphcount]. another error to catch is giving the install a font that doesn't exist...

NNBnh commented 3 years ago

10 Here is my attempt

alexmyczko commented 3 years ago

@NNBnh thanks, I hope you don't mind me editing your attempt and then applying?

alexmyczko commented 3 years ago

shellcheck /usr/bin/fnt

In /usr/bin/fnt line 49: if [ ! $? -eq 0 ]; then ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

In /usr/bin/fnt line 74: ls -1 $HOME/Library/Fonts/.?tf $HOME/.fonts/.?tf 2>/dev/null | while read f; do ^-- SC2012: Use find instead of ls to better handle non-alphanumeric filenames. ^---^ SC2086: Double quote to prevent globbing and word splitting. ^---^ SC2086: Double quote to prevent globbing and word splitting. ^--^ SC2162: read without -r will mangle backslashes.

Did you mean: ls -1 "$HOME"/Library/Fonts/.?tf "$HOME"/.fonts/.?tf 2>/dev/null | while read f; do

In /usr/bin/fnt line 75: echo "$f" [$(otfinfo -u "$f" 2>/dev/null|wc -l|awk '{print $1}')] | sed s,.*/,, ^-- SC2046: Quote this to prevent word splitting.

For more information: https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt... https://www.shellcheck.net/wiki/SC2012 -- Use find instead of ls to better ... https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...

alexmyczko commented 3 years ago

good enough.