ShellCheck fixes WIP (related to #120)

This commit is contained in:
Ryan L McIntyre 2018-01-12 22:20:52 -05:00
parent e8cf985c63
commit 338b0c6bdc
12 changed files with 101 additions and 80 deletions

View file

@ -9,6 +9,6 @@ echo "dir $dir"
"${dir}/autohint.sh" "$fontfile"
"${dir}/../fpfix.py" "$fontfile"
printf "\n"
printf "[Nerd Fonts] Post Processed Hack '%s'\n" "$fontfile"
printf "\\n"
printf "[Nerd Fonts] Post Processed Hack '%s'\\n" "$fontfile"

View file

@ -2,6 +2,7 @@
# version: 1.2.0
# Generates CSS file for the font
# shellcheck disable=SC1091
source ./lib/i_all.sh
output_css_file="../../css/nerd-fonts-generated.css"
@ -11,17 +12,17 @@ LINE_PREFIX="# [Nerd Fonts] "
version="1.2.0"
# clear files
> "$output_css_file" 2> /dev/null
> "$output_cheat_sheet_file" 2> /dev/null
true > "$output_css_file" 2> /dev/null
true > "$output_cheat_sheet_file" 2> /dev/null
# describe how the classes were established
{
printf "/*\n"
printf " *%s Website: https://www.nerdfonts.com\n" "$LINE_PREFIX"
printf " *%s Development Website: https://github.com/ryanoasis/nerd-fonts\n" "$LINE_PREFIX"
printf " *%s Version: %s\n" "$LINE_PREFIX" "$version"
printf " *%s The following is generated from the build script\n" "$LINE_PREFIX"
printf " */\n\n"
printf "/*\\n"
printf " *%s Website: https://www.nerdfonts.com\\n" "$LINE_PREFIX"
printf " *%s Development Website: https://github.com/ryanoasis/nerd-fonts\\n" "$LINE_PREFIX"
printf " *%s Version: %s\\n" "$LINE_PREFIX" "$version"
printf " *%s The following is generated from the build script\\n" "$LINE_PREFIX"
printf " */\\n\\n"
# add top section of CSS
cat $header_css_file
} >> "$output_css_file"
@ -49,25 +50,25 @@ for var in "${!i@}"; do
# generate css rules
{
printf ".nf-%s:before, .nerd-font-%s:before, .nerd-fonts-%s:before {" "$glyph_name" "$glyph_name" "$glyph_name"
printf "\n"
printf " content: \"\%s\";" "$glyph_code"
printf "\n"
printf "\\n"
printf " content: \"\\%s\";" "$glyph_code"
printf "\\n"
printf "}"
printf "\n"
printf "\\n"
} >> "$output_css_file"
# generate HTML cheat sheet
{
printf "<div class=\"column\">"
printf "\n"
printf "\\n"
printf " <div class=\"nerd-font nerd-font-%s center\"></div>" "$glyph_name"
printf "\n"
printf "\\n"
printf " <span>nf-%s <br/>(%s)</span>" "$glyph_name" "$glyph_code"
printf "\n"
printf "\\n"
printf "</div>"
printf "\n"
printf "\\n"
} >> "$output_cheat_sheet_file"
done
printf "Generated CSS and Cheat Sheet HTML\n"
printf "Generated CSS and Cheat Sheet HTML\\n"

View file

@ -18,7 +18,7 @@ cd $unpatched_parent_dir || {
}
# clear output file (needed for multiple runs or updates):
> "$to" 2> /dev/null
true > "$to" 2> /dev/null
# add to the file
{
@ -60,6 +60,6 @@ done
# add to the file
{
printf "\n</fontconfig>\n"
printf "\\n</fontconfig>\\n"
} >> "$to"

View file

@ -1,8 +1,8 @@
#!/bin/bash
# version: 1.2.0
# used for debugging
#set -x
# used for debugging
#set -x
# for executing script to rebuild JUST the readmes:
# ./gotta-patch-em-all-font-patcher\!.sh "" info
@ -75,9 +75,11 @@ function patch_font {
# source the font config file if exists:
if [ -f "$config_dir/config.cfg" ]
then
# shellcheck source=/dev/null
source "$config_dir/config.cfg"
elif [ -f "$config_parent_dir/config.cfg" ]
then
# shellcheck source=/dev/null
source "$config_parent_dir/config.cfg"
fi
@ -88,13 +90,15 @@ function patch_font {
post_process=""
fi
# shellcheck disable=SC2154
# we know the '$config_has_powerline' is from the sourced file
if [ "$config_has_powerline" ]
then
powerline=""
combinations=$(printf "./font-patcher ${f##*/} %s\n" {' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
combinations=$(printf "./font-patcher ${f##*/} %s\\n" {' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
else
powerline="--powerline"
combinations=$(printf "./font-patcher ${f##*/} %s\n" {' --powerline',}{' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
combinations=$(printf "./font-patcher ${f##*/} %s\\n" {' --powerline',}{' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
fi
cd "$parent_dir" || {
@ -138,19 +142,21 @@ function generate_info {
# source the font config file if exists:
if [ -f "$config_dir/config.cfg" ]
then
# shellcheck source=/dev/null
source "$config_dir/config.cfg"
elif [ -f "$config_parent_dir/config.cfg" ]
then
# shellcheck source=/dev/null
source "$config_parent_dir/config.cfg"
fi
if [ "$config_has_powerline" ]
then
powerline=""
combinations=$(printf "./font-patcher ${f##*/} %s\n" {' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
combinations=$(printf "./font-patcher ${f##*/} %s\\n" {' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
else
powerline="--powerline"
combinations=$(printf "./font-patcher ${f##*/} %s\n" {' --powerline',}{' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
combinations=$(printf "./font-patcher ${f##*/} %s\\n" {' --powerline',}{' --use-single-width-glyphs',}{' --windows',}{' --fontawesome',}{' --octicons',}{' --fontlinux',}{' --pomicons',}{' --powerlineextra',}{' --fontawesomeextension',}{' --powersymbols',})
fi
font_families_count=$((font_families_count+1))
@ -184,7 +190,7 @@ function generate_readme {
local font_info="$patched_font_dir/font-info.md"
# clear output file (needed for multiple runs or updates):
> "$combinations_filename"
true > "$combinations_filename"
if [ -f "$font_info" ];
then
@ -202,16 +208,16 @@ function generate_readme {
# add to the file
{
printf "\`\`\`sh"
printf "\n# %s Possible Combinations:\n" "$combination_count"
printf "\n"
printf "\\n# %s Possible Combinations:\\n" "$combination_count"
printf "\\n"
printf "%s" "$combinations"
printf "\n"
printf "\\n"
printf "\`\`\`"
} >> "$combinations_filename"
fi
}
if [ ! $info_only ]
if [ ! "$info_only" ]
then
# Iterate through source fonts
for i in "${!source_fonts[@]}"
@ -227,7 +233,7 @@ then
# however we want to run a certain number in parallel to decrease
# the amount of time patching all the fonts will take
# for now set a 'wait' for each X set of processes:
if [[ $(($i % $max_parallel_process)) == 0 ]];
if [[ $((i % max_parallel_process)) == 0 ]];
then
echo "$LINE_PREFIX Complete Variation Count after max parallel process is $complete_variation_count"
wait
@ -259,11 +265,11 @@ dt3=$(echo "$dt2-3600*$dh" | bc)
dm=$(echo "$dt3/60" | bc)
ds=$(echo "$dt3-60*$dm" | bc)
printf "$LINE_PREFIX Total runtime: %d:%02d:%02d:%02d\n" "$dd" "$dh" "$dm" "$ds"
printf "$LINE_PREFIX Total runtime: %d:%02d:%02d:%02d\\n" "$dd" "$dh" "$dm" "$ds"
printf "# All fonts patched to sub-directories in \t\t\t'%s'\n" "$patched_parent_dir"
printf "# The total number of font typefaces patched was \t\t'%s'\n" "$font_typefaces_count"
printf "# The total number of font families patched was \t\t'%s'\n" "$font_families_count"
printf "# The total number of 'complete' patched fonts created was \t'%s'\n" "$complete_variation_count"
printf "# The total number of 'variation' patched fonts created was \t'%s'\n" "$total_variation_count"
printf "# The total number of patched fonts created was \t\t'%s'\n" "$total_count"
printf "# All fonts patched to sub-directories in \\t\\t\\t'%s'\\n" "$patched_parent_dir"
printf "# The total number of font typefaces patched was \\t\\t'%s'\\n" "$font_typefaces_count"
printf "# The total number of font families patched was \\t\\t'%s'\\n" "$font_families_count"
printf "# The total number of 'complete' patched fonts created was \\t'%s'\\n" "$complete_variation_count"
printf "# The total number of 'variation' patched fonts created was \\t'%s'\\n" "$total_variation_count"
printf "# The total number of patched fonts created was \\t\\t'%s'\\n" "$total_count"

View file

@ -1,6 +1,7 @@
#!/bin/bash
for i in $(dirname "${BASH_SOURCE[0]:-$0}")/i_{dev,fae,fa,iec,linux,oct,ple,pom,seti}.sh; do
# shellcheck source=/dev/null
test -f "$i" -a -r "$i" && source "$i"
done
unset i

View file

@ -24,7 +24,7 @@ function appendRfnInfo {
then
# add to the file
{
printf "\n## Why \`%s\` and not \`%s\`?\n" "$config_rfn_substitue" "$config_rfn"
printf "\\n## Why \`%s\` and not \`%s\`?\\n" "$config_rfn_substitue" "$config_rfn"
cat "$working_dir/../../src/readme-rfn-addendum.md"
} >> "$to"
fi
@ -35,7 +35,7 @@ function clearDestination {
local to=$1; shift
[[ -d "$to_dir" ]] || mkdir -p "$to_dir"
# clear output file (needed for multiple runs or updates):
> "$to" 2> /dev/null
true > "$to" 2> /dev/null
}
#find ./ProFont -type d | # uncomment to test 1 font (with txt)
@ -67,6 +67,7 @@ do
# source the font config file if exists:
if [ -f "$searchdir/config.cfg" ]
then
# shellcheck source=/dev/null
source "$searchdir/config.cfg"
else
# reset the variables
@ -145,7 +146,7 @@ do
clearDestination "$to_dir" "$to"
{
printf "# %s\n\n" "$base_directory"
printf "# %s\\n\\n" "$base_directory"
} >> "$to"
appendRfnInfo "$config_rfn" "$config_rfn_substitue" "$PWD" "$to"

View file

@ -27,6 +27,8 @@ function print-decimal-unicode-range() {
# add fillers to array to maintain table:
if [[ "$leftoverSpaces" < "$wrapAt" ]]; then
# shellcheck disable=SC2034
# needs rework without 'i' var?
for i in $(seq 1 $leftoverSpaces); do
originalSequence+=(0)
done
@ -34,15 +36,16 @@ function print-decimal-unicode-range() {
local sequenceLength=${#originalSequence[@]}
printf "%b\n" "$topLine"
printf "%b\\n" "$topLine"
for decimalCode in "${originalSequence[@]}"; do
local hexCode=$(printf '%x' "${decimalCode}")
local hexCode
hexCode=$(printf '%x' "${decimalCode}")
local code="${hexCode}"
local char="\u${hexCode}"
local char="\\u${hexCode}"
# fill in placeholder cells properly formatted:
if [ "${char}" = "\u0" ]; then
if [ "${char}" = "\\u0" ]; then
char=" "
code=" "
fi
@ -63,12 +66,12 @@ function print-decimal-unicode-range() {
fi
printf "%b%b%b" "$bar" "$allCodes" "$reset_color"
printf "\n"
printf "\\n"
printf "%b%b%b" "$bar" "$allChars" "$reset_color"
printf "\n"
printf "\\n"
if [ "$counter" != "$sequenceLength" ]; then
printf "%b\n" "$line"
printf "%b\\n" "$line"
fi
allCodes=""
@ -77,7 +80,7 @@ function print-decimal-unicode-range() {
done
printf "%b\n" "$bottomLine"
printf "%b\\n" "$bottomLine"
}

View file

@ -6,14 +6,22 @@ text2='Nerd Fonts'
leftSymbolsCodes=('E0B0' 'E0B4' 'E0B8' 'E0BC' 'E0C0' 'E0C4' 'E0C6' 'E0C8' 'E0CC' 'E0CE' 'E0CF' 'E0CF' 'E0D1' 'E0D2')
rightSymbolsCodes=('E0B2' 'E0B6' 'E0BA' 'E0BE' 'E0C2' 'E0C5' 'E0C7' 'E0C8' 'E0CC' 'E0CE' 'E0CF' 'E0CF' 'E0D1' 'E0D4')
# shellcheck disable=SC2034
# don't check unused vars we might want to use them later on
colorReset='\033[0m'
colorBgWhite='\033[107m'
# shellcheck disable=SC2034
# don't check unused vars we might want to use them later on
colorBgLightBlue='\033[104m' # light blue, bright green is 102
colorBgBlack='\033[40m'
colorBg1='\033[100m'
colorBg2=$colorBgBlack
# shellcheck disable=SC2034
# don't check unused vars we might want to use them later on
colorFgLightBlue='\033[94m'
colorFgLightGray='\033[90m'
# shellcheck disable=SC2034
# don't check unused vars we might want to use them later on
colorFgLightYellow='\033[93m'
colorFgBlack='\033[30m'
colorFg1=$colorFgBlack
@ -23,18 +31,18 @@ colorBgDefault='\033[49m'
echo -e "$colorReset Nerd Fonts :: Testing Powerline Symbol size and alignment"
for i in "${!leftSymbolsCodes[@]}"; do
symbol="\u${leftSymbolsCodes[$i]}"
symbol2="\u${rightSymbolsCodes[$i]}"
symbol="\\u${leftSymbolsCodes[$i]}"
symbol2="\\u${rightSymbolsCodes[$i]}"
code="${leftSymbolsCodes[$i]}"
code2="${rightSymbolsCodes[$i]}"
if [ "$code" = "$code2" ]; then
symbol2="\u${rightSymbolsCodes[0]}"
symbol2="\\u${rightSymbolsCodes[0]}"
code2='None'
fi
echo -e "$colorBg1$colorFg1$text1 $code $colorFg2$colorBg2$symbol $text2 $colorFg1$colorBgDefault$symbol -- $colorFg1$colorBgDefault$symbol2$colorFg2$colorBg2 $text2 $symbol2$colorBg1$colorFg1 $code2 $colorReset$colorBgWhite\n$colorReset"
echo -e "$colorBg1$colorFg1$text1 $code $colorFg2$colorBg2$symbol $text2 $colorFg1$colorBgDefault$symbol -- $colorFg1$colorBgDefault$symbol2$colorFg2$colorBg2 $text2 $symbol2$colorBg1$colorFg1 $code2 $colorReset$colorBgWhite\\n$colorReset"
done
printf "\n"
printf "\\n"

View file

@ -6,13 +6,13 @@ echo "Click to start"
# Window geometry
# source: https://www.maketecheasier.com/record-screen-as-animated-gif-ubuntu/
XWININFO=$(xwininfo)
read X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO")
read Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO")
read W < <(awk -F: '/Width/{print $2}' <<< "$XWININFO")
read H < <(awk -F: '/Height/{print $2}' <<< "$XWININFO")
read -r X < <(awk -F: '/Absolute upper-left X/{print $2}' <<< "$XWININFO")
read -r Y < <(awk -F: '/Absolute upper-left Y/{print $2}' <<< "$XWININFO")
read -r W < <(awk -F: '/Width/{print $2}' <<< "$XWININFO")
read -r H < <(awk -F: '/Height/{print $2}' <<< "$XWININFO")
byzanz-record -c --exec=./test-fonts.sh --x=$X --y=$Y --width=$W --height=$H "rec3.gif"
byzanz-record -c --exec=./test-fonts.sh --x="$X" --y="$Y" --width="$W" --height="$H" "rec3.gif"
convert -coalesce "rec3.gif" "results/nerd-fonts.png"
convert -append $(ls -v results/*.png) ./test-combined.png
convert -append $"(ls -v results/*.png)" ./test-combined.png

View file

@ -16,12 +16,15 @@ private_config="../private.cfg"
# source the private confit file if exists:
if [ -f "$private_config" ]
then
# shellcheck source=/dev/null
source "$private_config"
else
echo >&2 "$LINE_PREFIX Could not source private config"
exit 1
fi
# shellcheck disable=SC2154
# # we know the '$github_access_token' is from the sourced file
TOKEN=$github_access_token
OWNER="ryanoasis"
REPO="nerd-fonts"
@ -63,7 +66,7 @@ do
printf "$LINE_PREFIX Uploading %s" "$basename"
curl -# -XPOST -H "Authorization:token $TOKEN" -H "Content-Type:application/octet-stream" --data-binary @"$basename" https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASE/assets?name="$basename"
curl -# -XPOST -H "Authorization:token $TOKEN" -H "Content-Type:application/octet-stream" --data-binary @"$basename" https://uploads.github.com/repos/"$OWNER"/"$REPO"/releases/"$RELEASE"/assets?name="$basename"
#exit # uncomment to test only 1 zip

View file

@ -15,9 +15,9 @@ fi
release=$1
sed -i "s|[0-9]\.[0-9]\.[0-9]|$release|g" ../../font-patcher
sed -i "s|\# version: [0-9]\.[0-9]\.[0-9]|\# version: $release|g" ../../bin/scripts/*.sh
sed -i "s|version=\"[0-9]\.[0-9]\.[0-9]\"|version=\"$release\"|g" ../../bin/scripts/*.sh
sed -i "s|[0-9]\\.[0-9]\\.[0-9]|$release|g" ../../font-patcher
sed -i "s|\\# version: [0-9]\\.[0-9]\\.[0-9]|\\# version: $release|g" ../../bin/scripts/*.sh
sed -i "s|version=\"[0-9]\\.[0-9]\\.[0-9]\"|version=\"$release\"|g" ../../bin/scripts/*.sh
exit

View file

@ -1,13 +1,11 @@
#!/bin/bash
# Install Nerd Fonts
__ScriptVersion="0.2"
__ScriptVersion="0.3"
# Default values for option variables:
quiet=false
mode="copy"
clean=false
mono=false
windows=false
extension="otf"
patches=("Complete")
compat=()
@ -110,7 +108,7 @@ while getopts "$optspec" optchar; do
# If the user has picked one of these options,
# we need to unset `Complete`
delete=("Complete")
patches=( "${patches[@]/$delete}" )
patches=( "${patches[@]/${delete[0]}}" )
case "${OPTARG}" in
fontawesome) patches=( "${patches[@]}" "Font Awesome" );;
fontlinux) patches=( "${patches[@]}" "Font Linux" );;
@ -133,7 +131,7 @@ while getopts "$optspec" optchar; do
esac
done
shift $(($OPTIND-1))
shift $((OPTIND-1))
# Set source and target directories, default: all fonts
nerdfonts_root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/patched-fonts"
@ -146,7 +144,7 @@ if [ ! -z "$*" ]; then
if [ ! -z "$font" ]; then
# Ensure that directory exists, and offer suggestions if not
if [[ ! -d "$nerdfonts_root_dir/$font" ]]; then
echo -e "Font $font doesn't exist. Options are: \n"
echo -e "Font $font doesn't exist. Options are: \\n"
find "$nerdfonts_root_dir" -maxdepth 1 -type d \( \! -name "$(basename "$nerdfonts_root_dir")" \) -exec basename {} \;
exit -1
fi
@ -164,7 +162,7 @@ implode() {
# $3... are the elements to join
local retname=$1 sep=$2 ret=$3
shift 3 || shift $(($#))
printf -v "$retname" "%s" "$ret${@/#/$sep}"
printf -v "$retname" "%s" "$ret${*/#/$sep}"
}
find_include=
find_exclude=
@ -179,7 +177,7 @@ if [ ! -z "${compat[*]}" ]; then
fi
# Delete empty elements
for i in "${!include[@]}"; do
[ "${include[$i]}" = '' ] && unset include[$i]
[ "${include[$i]}" = '' ] && unset include["$i"]
done
if [ ! -z "${include[*]}" ]; then
implode find_include "*' -and -name '*" "${include[@]}"
@ -193,11 +191,11 @@ for delete in "${include[@]}"; do
done
# Delete empty elements
for i in "${!exclude[@]}"; do
[ "${exclude[$i]}" = '' ] && unset exclude[$i]
[ "${exclude[$i]}" = '' ] && unset exclude["$i"]
done
if [ ! -z "${exclude[*]}" ]; then
implode find_exclude "*' -and \! -name '*" "${exclude[@]}"
find_exclude="-and \! -name '*${find_exclude}*'"
implode find_exclude "*' -and \\! -name '*" "${exclude[@]}"
find_exclude="-and \\! -name '*${find_exclude}*'"
fi
# Construct directories to be searched
@ -205,7 +203,7 @@ implode find_dirs "\" \"" "${nerdfonts_dirs[@]}"
find_dirs="\"$find_dirs\""
# Put it all together into the find command we want
find_command="find $find_dirs \( \( -name '*.[o,t]tf' -or -name '*.pcf.gz' \) $find_include $find_exclude \) -type f -print0"
find_command="find $find_dirs \\( \\( -name '*.[o,t]tf' -or -name '*.pcf.gz' \\) $find_include $find_exclude \\) -type f -print0"
# Find all the font files and store in array
files=()
@ -226,12 +224,12 @@ done
# Remove duplicates
for i in "${!files_dedup[@]}"; do
for j in "${!files_dedup[@]}"; do
[ $i = $j ] && continue
[ "$i" = "$j" ] && continue
if [ "${files_dedup[$i]}" = "${files_dedup[$j]}" ]; then
ext="${files[$i]##*.}"
# Only remove if the extension is the one we dont want
if [ "$ext" != "$extension" ]; then
unset files[$i]
unset files["$i"]
fi
fi
done