From 41cc67a3efcd0bafd2cc2bda5ac3f119a32dad24 Mon Sep 17 00:00:00 2001 From: Eugene Kalinin Date: Mon, 28 Sep 2026 23:03:13 +0300 Subject: [PATCH] refactor(lint): fix shellcheck warnings --- gh-md-toc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gh-md-toc b/gh-md-toc index bce5271..9a8b9e0 100755 --- a/gh-md-toc +++ b/gh-md-toc @@ -167,7 +167,7 @@ gh_toc(){ exit 1 fi local toc - toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy" "$indent"` + toc=$(echo "$rawhtml" | gh_toc_grab "$gh_src_copy" "$indent") echo "$toc" if [ "$need_replace" = "yes" ]; then if grep -Fxq "" "$gh_src" && grep -Fxq "" "$gh_src"; then @@ -184,7 +184,7 @@ gh_toc(){ local toc_path="${gh_src}.toc.${dt}" local toc_createdby="" local toc_footer - toc_footer="" + toc_footer="" # http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html # clear old TOC sed -i"${ext}" "/${ts}/,/${te}/{//!d;}" "$gh_src" @@ -243,9 +243,10 @@ gh_toc_grab() { } print sprintf("%*s", (level-1)*'"$2"', "") "* [" text "](" gh_url modified_href ")" ' - if [ "`uname -s`" == "OS/390" ]; then + if [ "$(uname -s)" == "OS/390" ]; then grepcmd="pcregrep -o" echoargs="" + # shellcheck disable=SC2016 awkscript='{ level = substr($0, 3, 1) text = substr($0, match($0, /<\/span><\/a>[^<]*<\/h/)+11, RLENGTH-14) @@ -255,6 +256,7 @@ gh_toc_grab() { else grepcmd="grep -Eo" echoargs="-e" + # shellcheck disable=SC2016 awkscript='{ level = substr($0, 3, 1) text = substr($0, match($0, /">.*<\/h/)+2, RLENGTH-5) @@ -302,10 +304,10 @@ gh_toc_get_filename() { show_version() { echo "$gh_toc_version" echo - echo "os: `uname -s`" - echo "arch: `uname -m`" - echo "kernel: `uname -r`" - echo "shell: `$SHELL --version`" + echo "os: $(uname -s)" + echo "arch: $(uname -m)" + echo "kernel: $(uname -r)" + echo "shell: $($SHELL --version)" echo for tool in curl wget grep awk sed; do printf "%-5s: " $tool @@ -368,7 +370,7 @@ gh_toc_app() { mkdir -p "$TMPDIR" fi local gh_tmp_md - if [ "`uname -s`" == "OS/390" ]; then + if [ "$(uname -s)" == "OS/390" ]; then local timestamp timestamp=$(date +%m%d%Y%H%M%S) gh_tmp_md="$TMPDIR/tmp.$timestamp"