From 6417d76f119223ffb8bed379f8d9f1af56e13fbf Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 11:56:49 +0100 Subject: [PATCH 01/47] SC2148 - shebang --- bash/habitual/std.functions | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 6fd2ed3..8c520d1 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -1,3 +1,4 @@ +#!/bin/env bash # vim: et sr sw=4 ts=4 smartindent syntax=sh: # @overview From 3c20de7f4b8a3418e6086af0c7d175039e35d360 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 13:56:37 +0100 Subject: [PATCH 02/47] SC2034: remove unused var, SC1090: ignore --- bash/habitual/std.functions | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 8c520d1..5d84ee7 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -29,11 +29,12 @@ # source_files() { local files=("$@") - local f="" i="" rc=0 + local f="" rc=0 for f in "${files[@]}"; do if [[ -e "$f" ]]; then d "... sourcing $f" + #shellcheck disable=SC1090 ! . "$f" && e "... can not source $f" && rc=1 else if [[ -z "$IGNORE_MISSING" ]]; then From be541bd3bccb0ac246297ecdecd6054dc6e1eb78 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 13:57:34 +0100 Subject: [PATCH 03/47] SC2086: double-quote --- bash/habitual/std.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 5d84ee7..c1dea80 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -93,7 +93,7 @@ required_vars() { local required_vars="$1" local this_var="" for this_var in $required_vars; do - if ! check_var_defined $this_var + if ! check_var_defined "$this_var" then failed="${failed}\$$this_var " rc=1 From fb04d93256bdacf81ad75a6908be695b09d72a1e Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 13:58:44 +0100 Subject: [PATCH 04/47] SC2236: -n instead ! -z --- bash/habitual/std.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index c1dea80..befbc58 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -113,7 +113,7 @@ required_vars() { # # ... test to see $FOO and $BAR are non-empty. # check_var_defined "FOO" || echo "FOO is empty or not defined" # -check_var_defined() { [[ ! -z "${!1}" ]] ; } +check_var_defined() { [[ -n "${!1}" ]] ; } # @desc Trim leading and trailing whitespace from a string # From 326588a23a85955d7676dd777ceff1026e148124 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:00:59 +0100 Subject: [PATCH 05/47] SC2181: if-cmd --- bash/habitual/std.functions | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index befbc58..f08a8c3 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -183,10 +183,13 @@ std::render_tmpl() { fi cmd="cat <<$delim"$'\n'"$d"$'\n'"$delim" # creates a heredoc - eval "$cmd" # ... check eval worked syntactically ... - [[ $? -ne 0 ]] && e "... failed to render file $file_tmpl" && return 1 + if ! eval "$cmd" + then + e "... failed to render file $file_tmpl" + return 1 + fi return 0 } From 5c9eb9e79a8b83284cb25c156ac5f9f874a003f3 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:03:00 +0100 Subject: [PATCH 06/47] SC2016:disable, due to no need to expand and more readable with this way --- bash/habitual/std.functions | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index f08a8c3..e747628 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -196,6 +196,7 @@ std::render_tmpl() { _stop_breakouts_in_render() { local d="$1" + #shellcheck disable=SC2016 echo "$d" \ | sed \ -e 's/\([^\\]\)`/\1\\`/g' `# catch backticks preceded by non-backslash` \ From 51d2a12e6ef1388bcc2d6c9f399a17b6b585c79e Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:09:12 +0100 Subject: [PATCH 07/47] SC2001, SC2181 --- bash/habitual/std.functions | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index e747628..246cb1f 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -268,6 +268,7 @@ str_to_safe_chars() { local s="$1" # str to transform local r="${2:-_}" # replacement char local p="${3:-$(safe_chars_def_list)}" # allowed chars (or with leading ! disallowed) + local sed_cmd="" [[ -z "$1" ]] && red_e "... you must pass a str to transform" && return 1 [[ "${#r}" -ne 1 ]] && red_e "... replacement must be one UTF-8 char, not '$r'" && return 1 @@ -281,16 +282,16 @@ str_to_safe_chars() { # GNU tr does not handle UTF8 correctly, so sed is used instead # ... user may pass '/' to $r which would mess with default sed delimiter. if [[ "$r" == '/' ]]; then - echo "$s" | sed -e "s#$sed_class#$r#g" + sed_cmd="echo '$s' | sed -e 's#$sed_class#$r#g'" else - echo "$s" | sed -e "s/$sed_class/$r/g" + sed_cmd="echo '$s' | sed -e 's/$sed_class/$r/g'" fi - if [[ $? -eq 0 ]]; then - return 0 - else + + if ! eval "$sed_cmd"; then e "... unable to make safe\nstr: $s\nreplacement char: $r\nchar list: $p\ncl:$sed_class" return 1 fi + return 0 } # @desc Prints default list of allowed chars for From b6a8e4ecfcee930f0c5d954ff8bfee7acea6a272 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:10:25 +0100 Subject: [PATCH 08/47] SC2086: double-qoute --- bash/habitual/std.functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 246cb1f..3daf6b8 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -368,7 +368,7 @@ semver_a_ge_b() { if [[ "$a" =~ \- ]] && [[ "$b" =~ \- ]]; then # ... both are prerelease, just compare originals with out leading vVs - _semver_a_gt_b ${a##[vV]} ${b##[vV]} + _semver_a_gt_b "${a##[vV]}" "${b##[vV]}" return $? elif [[ "$a" =~ \- ]] ; then @@ -378,7 +378,7 @@ semver_a_ge_b() { fi fi - _semver_a_gt_b $va $vb + _semver_a_gt_b "$va" "$vb" } From 0486b7ec017e8ba0ffd5ded006370ffde957c059 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:11:56 +0100 Subject: [PATCH 09/47] SC2236: Use -n instead of ! -z. --- bash/habitual/std.functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 3daf6b8..8b718bb 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -404,7 +404,7 @@ _semver_a_gt_b() { # possible to construct it. # export_build_url() { - if [[ ! -z "$CIRCLE_BUILD_URL" ]]; then + if [[ -n "$CIRCLE_BUILD_URL" ]]; then BUILD_URL="$CIRCLE_BUILD_URL" elif [[ "$TRAVIS" == "true" ]]; then if required_vars "TRAVIS_REPO_SLUG TRAVIS_JOB_ID" @@ -412,7 +412,7 @@ export_build_url() { BUILD_URL="https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID" fi fi - [[ ! -z "$BUILD_URL" ]] && export BUILD_URL + [[ -n "$BUILD_URL" ]] && export BUILD_URL } ##################################################################### From 7a33f9c9abf33fd9edf75d07cba4e4b61aa5a181 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:21:51 +0100 Subject: [PATCH 10/47] SC2086: weird one --- bash/habitual/std.functions | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 8b718bb..1160891 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -466,6 +466,8 @@ set_log_prefix() { echo "${0#-}" else local src="" f="" func="" + # I don't think the one below is correct but suspect it's a bug + #shellcheck disable=SC2086 if [[ "$(caller ${FROM_STACKFRAME:-1})" =~ $__CALLER_REGX ]]; then src="${BASH_REMATCH[3]}" func_i=$(( $(( ${FROM_STACKFRAME:-1} + 1 )) )) From 7f5f2526bf9268fecfbcd64ee3d4f19dc3c7e72f Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:22:46 +0100 Subject: [PATCH 11/47] SC2236: Use -n instead of ! -z --- bash/habitual/std.functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 1160891..8f09ffc 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -478,12 +478,12 @@ set_log_prefix() { # ... if the cwd is changed, realpath may not work, so fall back to just $src f=$(realpath -- "$src" 2>/dev/null); [[ -z "$f" ]] && f=$src - if [[ ! -z "$DEBUG_ABS_PATHS" ]]; then + if [[ -n "$DEBUG_ABS_PATHS" ]]; then str=$f else str=$(basename "$f") fi - [[ ! -z "$func" ]] && str="$str:$func()" + [[ -n "$func" ]] && str="$str:$func()" echo $str fi } From eb046ef5135ad308e08e1bf1812b0a38a0ef057c Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:23:42 +0100 Subject: [PATCH 12/47] SC2086: Double-quote --- bash/habitual/std.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 8f09ffc..a6738b0 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -484,7 +484,7 @@ set_log_prefix() { str=$(basename "$f") fi [[ -n "$func" ]] && str="$str:$func()" - echo $str + echo "$str" fi } From 924d25582f6fe7381e04ccf91b1fbf2e362e9289 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:43:01 +0100 Subject: [PATCH 13/47] SC2155: Declare and assign separately, SC2162: read with -r --- bash/habitual/std.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index a6738b0..700cf26 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -511,12 +511,14 @@ set_log_prefix() { # e() { local IFS='' - local pre="ERROR $(set_log_prefix)" - while read line ; do + local pre + + pre="ERROR $(set_log_prefix)" + while read -r line ; do echo -e "$pre: $line" >&2 done < <(echo -e "$*\n") - while read line; do + while read -r line; do echo -e "$pre: ${__TRED}$line${__TRESET}" >&2 done < <(echo -e "TRACE:\n$(__stacktrace)") } From 754b0d778b61cd0c80f7fd024151c2883dd6885e Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:44:53 +0100 Subject: [PATCH 14/47] SC2155: Declare and assign separately, SC2162: read with -r --- bash/habitual/std.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 700cf26..005190a 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -538,10 +538,12 @@ e() { # # INFO script.sh:main(): ... line 3 # i() { - [[ ! -z "$QUIET" ]] && return 0 + [[ -n "$QUIET" ]] && return 0 local IFS='' - local pre="INFO $(set_log_prefix)" - while read line ; do + local pre + + pre="INFO $(set_log_prefix)" + while read -r line ; do echo -e "$pre: $line" done < <(echo -e "$*") } From b1ecdde720bf013ebe15f072b3a81174db4e252d Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:56:50 +0100 Subject: [PATCH 15/47] SC2236, SC2155, SC2162 --- bash/habitual/std.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 005190a..f16aa7c 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -564,11 +564,13 @@ i() { # @example # d "msg line 1" "line 2\nline3" d() { - [[ ! -z "$QUIET" ]] && return 0 + [[ -n "$QUIET" ]] && return 0 [[ -z "$DEBUG" ]] && return 0 local IFS='' - local pre="DEBUG $(set_log_prefix)" - while read line ; do + local pre + + pre="DEBUG $(set_log_prefix)" + while read -r line ; do echo -e "$pre: ${__TDEBUG}$line${__TRESET}" >&2 done < <(echo -e "$*") } From 8df50aa57d2e7a3f077d2f2e2713987fc00b1b9d Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 14:57:52 +0100 Subject: [PATCH 16/47] SC2236, SC2155, SC2162 --- bash/habitual/std.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index f16aa7c..5759af1 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -578,12 +578,14 @@ d() { # @desc as with e(), but msg text is coloured red_e() { local IFS='' - local pre="ERROR $(set_log_prefix)" - while read line ; do + local pre + + pre="ERROR $(set_log_prefix)" + while read -r line ; do echo -e "$pre: ${__TRED}$line${__TRESET}" >&2 done < <(echo -e "$*\n") - while read line; do + while read -r line; do echo -e "$pre: ${__TRED}$line${__TRESET}" >&2 done < <(echo -e "TRACE:\n$(__stacktrace)") } From e6a5076f2fba011eb93e4f0e1e94817568e4868a Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:01:07 +0100 Subject: [PATCH 17/47] SC2236, SC2155, SC2162 --- bash/habitual/std.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 5759af1..58d37ed 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -592,10 +592,12 @@ red_e() { # @desc as with i(), but msg text is highlighted bold_i() { - [[ ! -z "$QUIET" ]] && return 0 + [[ -n "$QUIET" ]] && return 0 local IFS='' - local pre="INFO $(set_log_prefix)" - while read line ; do + local pre + + pre="INFO $(set_log_prefix)" + while read -r line ; do echo -e "$pre: ${__TBOLD}$line${__TRESET}" done < <(echo -e "$*") } From 0d1fd4f025d97b1642adaf58a3c6fd18cc691c83 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:01:59 +0100 Subject: [PATCH 18/47] SC2236, SC2155, SC2162 --- bash/habitual/std.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 58d37ed..8c1dc63 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -604,10 +604,12 @@ bold_i() { # @desc as with i(), but msg text is coloured. yellow_i() { - [[ ! -z "$QUIET" ]] && return 0 + [[ -n "$QUIET" ]] && return 0 local IFS='' - local pre="INFO $(set_log_prefix)" - while read line ; do + local pre + + pre="INFO $(set_log_prefix)" + while read -r line ; do echo -e "$pre: ${__TYELLOW}$line${__TRESET}" done < <(echo -e "$*") } From 0a448644d5b1a4955e46f5bfe559dc8bb3754946 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:02:32 +0100 Subject: [PATCH 19/47] SC2236, SC2155, SC2162 --- bash/habitual/std.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 8c1dc63..3bbc6fb 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -616,10 +616,12 @@ yellow_i() { # @desc as with i(), but msg text is coloured. green_i() { - [[ ! -z "$QUIET" ]] && return 0 + [[ -n "$QUIET" ]] && return 0 local IFS='' - local pre="INFO $(set_log_prefix)" - while read line ; do + local pre + + pre="INFO $(set_log_prefix)" + while read -r line ; do echo -e "$pre: ${__TGREEN}$line${__TRESET}" done < <(echo -e "$*") } From 17cca4c2432a7fc75f58026e705c78231fb1a26f Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:03:01 +0100 Subject: [PATCH 20/47] SC2236, SC2155, SC2162 --- bash/habitual/std.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 3bbc6fb..75b6fc6 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -628,10 +628,12 @@ green_i() { # @desc as with i(), but msg text is coloured. blue_i() { - [[ ! -z "$QUIET" ]] && return 0 + [[ -n "$QUIET" ]] && return 0 local IFS='' - local pre="INFO $(set_log_prefix)" - while read line ; do + local pre + + pre="INFO $(set_log_prefix)" + while read -r line ; do echo -e "$pre: ${__TBLUE}$line${__TRESET}" done < <(echo -e "$*") } From 31319aff7857a956e507eff476c74dca1f5ae174 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:15:17 +0100 Subject: [PATCH 21/47] shebang fix --- bash/habitual/std.functions | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 75b6fc6..ebc25a4 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/usr/bin/env bash # vim: et sr sw=4 ts=4 smartindent syntax=sh: # @overview @@ -653,17 +653,17 @@ __stacktrace() { local frame=$start_index str="" while true; do - local st="" ln="" func="" file="" + local st="" ln="" func="" file="" indent="" tmpl="" - st=$(caller $frame) || break + st=$(caller "$frame") || break [[ "$st" =~ $__CALLER_REGX ]] \ && ln="${BASH_REMATCH[1]}" \ && func="${BASH_REMATCH[2]}" \ && file="${BASH_REMATCH[3]}" - local tmpl="%$(( $(( frame - $start_index )) * 2 ))s" - local indent="$(printf $tmpl)" + tmpl="%$(( $(( frame - $start_index )) * 2 ))s" + indent="$(printf $tmpl)" str_fmt="${indent}${func}() (file: $file, line: $ln)\n" str="$str$str_fmt" From d5a076f22e22a21ba35f88d69abf595cf93d80e5 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:16:22 +0100 Subject: [PATCH 22/47] shebang --- bash/habitual/git.functions | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 83e1665..31ca6a3 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # vim: et sr sw=4 ts=4 smartindent syntax=sh: # # @overview From dbff250906e890e43c6c5193297268f36f1a13a5 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:17:10 +0100 Subject: [PATCH 23/47] SC2236, SC2086 --- bash/habitual/git.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 31ca6a3..5269528 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -19,7 +19,7 @@ GIT_SHA_LEN=${GIT_SHA_LEN:-8} # __cd() - if user passed a path, cd to it. __cd() { local d="$1" - [[ ! -z "$d" ]] && ! cd $d 2>/dev/null && red_e "couldn't cd to $d" && return 1; + [[ -n "$d" ]] && ! cd "$d" 2>/dev/null && red_e "couldn't cd to $d" && return 1; return 0 } From dd7ca274f545818fb9e4c0bedd5e06891349b36b Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:18:11 +0100 Subject: [PATCH 24/47] SC2086 --- bash/habitual/git.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 5269528..841c754 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -44,7 +44,7 @@ git_repo() { # @desc Prints sha of current commit - up to $GIT\_SHA\_LEN chars. git_sha() { - ${GIT} rev-parse --short=${GIT_SHA_LEN} --verify HEAD + ${GIT} rev-parse --short="$GIT_SHA_LEN" --verify HEAD } # @desc Prints out the git-tag on the current commit (exact match only) From 63a1a3de01bf7ee4ead389bc6e9332150e6723e1 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:19:36 +0100 Subject: [PATCH 25/47] SC2155, SC2086 --- bash/habitual/git.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 841c754..65a4090 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -68,10 +68,12 @@ git_email() { # @desc Prints user.name user.email (from git config) # Returns 1 if user.name not set. git_id() { - local u=$(git_user) - local e=$(git_email) + local u="" e="" + + u=$(git_user) + e=$(git_email) [[ -z "$u" ]] && echo "" && return 1 - echo $u $e + echo "$u" "$e" } # @desc Outputs a str formed of repo, sha1, tag and branch info. From 8663d9cb2721506f0bedfe6b3477a49c884b143f Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:22:27 +0100 Subject: [PATCH 26/47] SC2086 --- bash/habitual/git.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 65a4090..5269509 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -94,7 +94,7 @@ git_info_str() { local branch="" repo="" sha="" tag="" ( - __cd $d || exit 1 + __cd "$d" || exit 1 ! in_git_clone && e "can't get git info for $(pwd) - not a git dir" && return 1 repo="$(git_repo)" From 97aeeaedee95e612263ea6a6c4428630863de41f Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:27:55 +0100 Subject: [PATCH 27/47] SC2155: Declare and assign separately --- bash/habitual/git.functions | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 5269509..c1db336 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -146,13 +146,20 @@ git_vars() { ! in_git_clone && e "... $PWD is not inside a git repo" && return 1 GIT_BRANCH="$(git_branch)" || return 1 ; export GIT_BRANCH - export GIT_TAG="$(git_tag)" - export GIT_REPO="$(git_repo)" - export GIT_SHA="$(git_sha)" - export GIT_USER="$(git_user)" - export GIT_EMAIL="$(git_email)" - export GIT_ID="$(git_id)" # git user and email, space separated - export GIT_INFO=$(_git_info_str "$GIT_REPO" "$GIT_SHA" "$GIT_TAG" "$GIT_BRANCH") + GIT_TAG="$(git_tag)" + export GIT_TAG + GIT_REPO="$(git_repo)" + export GIT_REPO + GIT_SHA="$(git_sha)" + export GIT_SHA + GIT_USER="$(git_user)" + export GIT_USER + GIT_EMAIL="$(git_email)" + export GIT_EMAIL + GIT_ID="$(git_id)" # git user and email, space separated + export GIT_ID + GIT_INFO=$(_git_info_str "$GIT_REPO" "$GIT_SHA" "$GIT_TAG" "$GIT_BRANCH") + export GIT_INFO } From 33c8529da8c37c69f818d0060c845896ffe535c2 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:29:49 +0100 Subject: [PATCH 28/47] SC2236, SC2155 --- bash/habitual/git.functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index c1db336..569e936 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -180,10 +180,12 @@ git_vars() { # DEVMODE=true no_unpushed_changes || exit 1 # no_unpushed_changes() { - [[ ! -z "${DEVMODE}" ]] && yellow_i "DEVMODE - skipping git checks" && return 0; + [[ -n "${DEVMODE}" ]] && yellow_i "DEVMODE - skipping git checks" && return 0; - local d=$(pwd) - local sha=$(git_sha) + local d="" sha="" + + d=$(pwd) + sha=$(git_sha) check_for_changes "$d" || return 1 sha_in_origin "$sha" || return 1 From 21b91a6b891f1fd7e716a61d71b55f2451992f2b Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:31:28 +0100 Subject: [PATCH 29/47] SC2119 --- bash/habitual/git.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 569e936..91adf0e 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -207,7 +207,7 @@ check_for_changes() { local d="${1:-$(pwd)}" i "... checking for uncommitted changes in $d" ( - __cd $d || exit 1 + __cd "$d" || exit 1 ! in_git_clone && red_e "$(pwd) is not a git dir" && return 1; git &>/dev/null --no-pager status # make sure index is up-to-date From 75178c010043f69ed341a7e466e66b79f35f0496 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:36:14 +0100 Subject: [PATCH 30/47] SC2181: ignore in here --- bash/habitual/git.functions | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 91adf0e..9f0eb55 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -250,7 +250,8 @@ sha_in_origin() { return 1 fi - b=$(git branch -r --contains ${sha} 2>/dev/null) + b=$(git branch -r --contains "$sha" 2>/dev/null) + #shellcheck disable=SC2181 if [[ $? -ne 0 ]] || [[ -z "$b" ]]; then red_e "This commit ($sha) does not exist on origin." red_e "Did you push these changes?" From c3753c16dad7a6207a117a2ebbe017fe3df04030 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:38:03 +0100 Subject: [PATCH 31/47] SC2086 --- bash/habitual/git.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 9f0eb55..33d82bc 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -277,7 +277,7 @@ in_git_clone() { local rc=0 local d="$1" ( - __cd $d || exit 1 + __cd "$d" || exit 1 git --no-pager rev-parse --is-inside-work-tree >/dev/null 2>&1 ) || rc=1 return $rc From 815c5ebc11230d2f295ef1eb49efdda096ceafa6 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:45:18 +0100 Subject: [PATCH 32/47] SC2148 --- bash/terraform/terraform_run.functions | 1 + 1 file changed, 1 insertion(+) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index 59b97ec..de98d8a 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # vim: et sr sw=4 ts=4 smartindent syntax=sh: # # @overview From 8a4eb85b35d90acd7e860531301569935b5c1626 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:46:41 +0100 Subject: [PATCH 33/47] SC2181 --- bash/terraform/terraform_run.functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index de98d8a..65d36fc 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -128,8 +128,8 @@ tf() { # terraform_version() { [[ -z "$TERRAFORM" ]] && TERRAFORM=$(tf) - $TERRAFORM --version | grep -Po '(?<=Terraform v)[\d\.]+' - if [[ $? -ne 0 ]] ; then + + if ! $TERRAFORM --version | grep -Po '(?<=Terraform v)[\d\.]+' ; then red_e "... could not determine version: used $TERRAFORM --version" return 1 fi From e53cb6ee8742fd2804c9db31c2c8aa5da5eea24a Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:47:21 +0100 Subject: [PATCH 34/47] SC2236: Use -n instead of ! -z. --- bash/terraform/terraform_run.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index 65d36fc..907391a 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -143,7 +143,7 @@ __special_modes() { _disclaimer_devmode() { local v='DEVMODE' - if [[ ! -z "${!v}" ]] ; then + if [[ -n "${!v}" ]] ; then yellow_i "=================================================" yellow_i "= ACTIVATED: \$${v}" yellow_i "=================================================" From 4d3de837eeba40e733e07a10836fcd1cc43422d2 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:47:53 +0100 Subject: [PATCH 35/47] SC2236: Use -n instead of ! -z. --- bash/terraform/terraform_run.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index 907391a..92eeb39 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -156,7 +156,7 @@ _disclaimer_devmode() { _disclaimer_keep_plugins() { local v='KEEP_PLUGINS' - if [[ ! -z "${!v}" ]] ; then + if [[ -n "${!v}" ]] ; then yellow_i "=================================================" yellow_i "= ACTIVATED: \$${v}" yellow_i "=================================================" From cfd0558ff29dcd63a22bd6072c62a0003343a9d5 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:48:11 +0100 Subject: [PATCH 36/47] SC2236: Use -n instead of ! -z. --- bash/terraform/terraform_run.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index 92eeb39..ed21fea 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -168,7 +168,7 @@ _disclaimer_keep_plugins() { _disclaimer_no_apply() { local v='NO_APPLY' - if [[ ! -z "${!v}" ]] ; then + if [[ -n "${!v}" ]] ; then yellow_i "=================================================" yellow_i "= ACTIVATED: \$${v}" yellow_i "=================================================" From eb4a85f5a9577242604b17ad5ec494ea23cbf7a7 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:49:50 +0100 Subject: [PATCH 37/47] SC2034: get_opts appears unused., SC2155: Declare and assign separately --- bash/terraform/terraform_run.functions | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index ed21fea..73f9ee0 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -205,8 +205,9 @@ terraform_cleanup() { # terraform_init() { local init_opts="$TERRAFORM_INIT_OPTS" # init / remote config opts - local get_opts="$TERRAFORM_GET_OPTS" - local tv=$(terraform_version) ; [[ -z "$tv" ]] && e "version of terrform not found" && return 1 + local tv + + tv=$(terraform_version) ; [[ -z "$tv" ]] && e "version of terrform not found" && return 1 # ... for terraform 0.9.0+ local init_cmd="init" get_cmd="" From 23de2f444b61e91271eef0bd3d4b63724e7cb61c Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:50:45 +0100 Subject: [PATCH 38/47] SC2236: Use -n instead of ! -z. --- bash/terraform/terraform_run.functions | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index 73f9ee0..5058889 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -221,12 +221,12 @@ terraform_init() { get_cmd="get" # need to get modules first. fi - if [[ ! -z "$DEVMODE" ]]; then - if [[ ! -z "$get_cmd" ]]; then + if [[ -n "$DEVMODE" ]]; then + if [[ -n "$get_cmd" ]]; then yellow_i "=================================================" yellow_i "... will run '$get_cmd' to fetch any modules" fi - if [[ ! -z "$init_opts" ]]; then + if [[ -n "$init_opts" ]]; then yellow_i "=================================================" yellow_i "= terraform $init_cmd opts:" yellow_i "=================================================" @@ -236,7 +236,7 @@ terraform_init() { fi # ... run terraform get if needed - [[ ! -z $get_cmd ]] && ! eval "$TERRAFORM get $TERRAFORM_GET_OPTS" && return 1 + [[ -n $get_cmd ]] && ! eval "$TERRAFORM get $TERRAFORM_GET_OPTS" && return 1 # ... now run init eval "$TERRAFORM $init_cmd $init_opts" } From 68f93603daab1464957387f94df9df7fe6d51958 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:51:10 +0100 Subject: [PATCH 39/47] SC2236: Use -n instead of ! -z. --- bash/terraform/terraform_run.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index 5058889..dd9e8a4 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -275,7 +275,7 @@ __skip_on() { local rc=1 for var_name in $flags; do - if [[ ! -z "${!var_name}" ]]; then + if [[ -n "${!var_name}" ]]; then d "... env var \$$var_name set." rc=0 fi From b386e7059333b88d00f569bced4a5cbe227a052f Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:52:45 +0100 Subject: [PATCH 40/47] SC2034: tf var appears unused, SC2086: Double quote --- bash/terraform/terraform_run.functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/terraform/terraform_run.functions b/bash/terraform/terraform_run.functions index dd9e8a4..871693c 100644 --- a/bash/terraform/terraform_run.functions +++ b/bash/terraform/terraform_run.functions @@ -366,7 +366,7 @@ __skip_on() { # terraform_run "/my/tf/dir" || exit 1 # unless DEVMODE, will apply terraform and switch dns. # terraform_run() { - local wd="$1" tf="" + local wd="$1" __special_modes @@ -378,7 +378,7 @@ terraform_run() { ( if [[ "$wd" ]]; then i "... changing to working dir $wd" - ! cd $wd && red_e "... could not change to $wd" && exit 1 + ! cd "$wd" && red_e "... could not change to $wd" && exit 1 fi terraform_cleanup || exit 1 From 00bb1b571d148a105d4d6daedd3501fa93054bda Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 15:57:28 +0100 Subject: [PATCH 41/47] run shellcheck tests --- shippable.build.sh | 2 +- shippable.test.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/shippable.build.sh b/shippable.build.sh index 211914e..20cfb4d 100644 --- a/shippable.build.sh +++ b/shippable.build.sh @@ -7,7 +7,7 @@ NVM_DIR=$CIUSER_HOME/.nvm install_tools() { sudo apt-get update - sudo apt-get install -y coreutils realpath + sudo apt-get install -y coreutils realpath shellcheck sort --help | grep -q -- '--version-sort' || return 1 # ...verify coreutils realpath $PWD >/dev/null || return 1 # ... verify realpath } diff --git a/shippable.test.sh b/shippable.test.sh index 7d9b27e..22e9eb9 100644 --- a/shippable.test.sh +++ b/shippable.test.sh @@ -25,6 +25,7 @@ run_bash_tests() { local rc=0 for lib in $(find_libs_to_test); do run_bash_test_file "$lib" || rc=1 + shellcheck "$lib" || rc=1 done return $rc } From 2f500c43e80e4499ddd54814fe68f653bd4e5c81 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Mon, 22 Jul 2019 17:01:12 +0100 Subject: [PATCH 42/47] install latest shellcheck --- shippable.build.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/shippable.build.sh b/shippable.build.sh index 20cfb4d..c48143a 100644 --- a/shippable.build.sh +++ b/shippable.build.sh @@ -7,9 +7,19 @@ NVM_DIR=$CIUSER_HOME/.nvm install_tools() { sudo apt-get update - sudo apt-get install -y coreutils realpath shellcheck + sudo apt-get install -y coreutils realpath curl xz-utils sort --help | grep -q -- '--version-sort' || return 1 # ...verify coreutils realpath $PWD >/dev/null || return 1 # ... verify realpath + # install the latest version of shellcheck + ( + cd /tmp \ + && curl -o shellcheck.tar.xz \ + https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz \ + && tar xvf shellcheck.tar.xz \ + && mv shellcheck-stable/shellcheck /usr/bin/ \ + && chmod +x /usr/bin/shellcheck + ) || return 1 + shellcheck --version | grep -E '^version:' || return 1 # ... verify shellcheck and print version } # workarounds because of quirky behaviour when building From eff28f4b2659831a2f0245b59d405d1e64da4b06 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Tue, 23 Jul 2019 17:15:51 +0100 Subject: [PATCH 43/47] no need for $ in c-like expressions --- bash/habitual/std.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index ebc25a4..51d3037 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -662,7 +662,7 @@ __stacktrace() { && func="${BASH_REMATCH[2]}" \ && file="${BASH_REMATCH[3]}" - tmpl="%$(( $(( frame - $start_index )) * 2 ))s" + tmpl="%$(( $(( frame - start_index )) * 2 ))s" indent="$(printf $tmpl)" str_fmt="${indent}${func}() (file: $file, line: $ln)\n" From fdfbcd6c02671ea955fcb6314cc54bc9f7eabc71 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Tue, 23 Jul 2019 17:47:44 +0100 Subject: [PATCH 44/47] disable SC2059 due to format should be templated to calculateindentation --- bash/habitual/std.functions | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index 51d3037..be51be8 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -663,7 +663,8 @@ __stacktrace() { && file="${BASH_REMATCH[3]}" tmpl="%$(( $(( frame - start_index )) * 2 ))s" - indent="$(printf $tmpl)" + #shellcheck disable=SC2059 + indent="$(printf $tmpl ' ')" str_fmt="${indent}${func}() (file: $file, line: $ln)\n" str="$str$str_fmt" From 8e2837349a179758b3d400fe736338552071f2fd Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Wed, 24 Jul 2019 11:02:43 +0100 Subject: [PATCH 45/47] SC2120 in git.functions --- bash/habitual/git.functions | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bash/habitual/git.functions b/bash/habitual/git.functions index 33d82bc..5d517f0 100644 --- a/bash/habitual/git.functions +++ b/bash/habitual/git.functions @@ -95,7 +95,12 @@ git_info_str() { ( __cd "$d" || exit 1 - ! in_git_clone && e "can't get git info for $(pwd) - not a git dir" && return 1 + # No need to call `cd` by sending $d in here for sure, + # but, shellcheck complains about SC2120 if you never + # call the function with an argument. + # It thinks you're confused about script's $1 and + # functions $1. So, no harm in this + ! in_git_clone "$d" && e "can't get git info for $(pwd) - not a git dir" && return 1 repo="$(git_repo)" sha="$(git_sha)" From cfeada4f08cc1fb94676f5fda24d06ed575507e2 Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Wed, 24 Jul 2019 11:19:04 +0100 Subject: [PATCH 46/47] t_str_to_safe_chars was failing due to quotation mistake, so disabled SC2001 instead --- bash/habitual/std.functions | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index be51be8..dc2ad5b 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -268,7 +268,7 @@ str_to_safe_chars() { local s="$1" # str to transform local r="${2:-_}" # replacement char local p="${3:-$(safe_chars_def_list)}" # allowed chars (or with leading ! disallowed) - local sed_cmd="" + local sed_rc="" [[ -z "$1" ]] && red_e "... you must pass a str to transform" && return 1 [[ "${#r}" -ne 1 ]] && red_e "... replacement must be one UTF-8 char, not '$r'" && return 1 @@ -282,12 +282,16 @@ str_to_safe_chars() { # GNU tr does not handle UTF8 correctly, so sed is used instead # ... user may pass '/' to $r which would mess with default sed delimiter. if [[ "$r" == '/' ]]; then - sed_cmd="echo '$s' | sed -e 's#$sed_class#$r#g'" + #shellcheck disable=SC2001 + echo "$s" | sed -e "s#$sed_class#$r#g" + sed_rc="$?" else - sed_cmd="echo '$s' | sed -e 's/$sed_class/$r/g'" + #shellcheck disable=SC2001 + echo "$s" | sed -e "s/$sed_class/$r/g" + sed_rc="$?" fi - if ! eval "$sed_cmd"; then + if [[ $sed_rc -ne 0 ]]; then e "... unable to make safe\nstr: $s\nreplacement char: $r\nchar list: $p\ncl:$sed_class" return 1 fi From dd5cd20b220e3fe07d40f615119eb9a0b6773b5d Mon Sep 17 00:00:00 2001 From: Levent Yalcin Date: Wed, 24 Jul 2019 11:43:01 +0100 Subject: [PATCH 47/47] I've got the idea wrong, so fixed now --- bash/habitual/std.functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash/habitual/std.functions b/bash/habitual/std.functions index dc2ad5b..b6d30ed 100644 --- a/bash/habitual/std.functions +++ b/bash/habitual/std.functions @@ -668,7 +668,7 @@ __stacktrace() { tmpl="%$(( $(( frame - start_index )) * 2 ))s" #shellcheck disable=SC2059 - indent="$(printf $tmpl ' ')" + indent="$(printf $tmpl)" str_fmt="${indent}${func}() (file: $file, line: $ln)\n" str="$str$str_fmt"