alexmyczko / fnt

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

🩹 Shellcheck fix, switch to POSIX shell and use /tmp #10

Closed NNBnh closed 3 years ago

NNBnh commented 3 years ago

In 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. ^--^ SC2162: read without -r will mangle backslashes.

In 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.

In fnt line 84: 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) ^----------------------^ SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

In fnt line 105: 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) ^----------------------^ SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

In fnt line 131: cat "$HOME/.fnt/Packages.xz" |unxz |grep ^Package:\ fonts-|awk '{print $2}' | grep "$2" ^----------------------^ SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

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/SC2162 -- read without -r will mangle backs...


- Make the script [POSIX-compatible and more portable](http://serverfault.com/questions/865874/ddg#865880):
```diff
- #!/usr/bin/env bash
+ #!/bin/sh
alexmyczko commented 3 years ago

the /tmp part is not multi user safe on a single machine, will review the rest as soon as i can, thank you.