Skip to content

Commit 973ea98

Browse files
VeryTastyTomatosharkdp
authored andcommitted
fix: warnings of ShellCheck
SC2155: Declare and assign separately to avoid masking return values. SC2164: Use cd ... || exit in case cd fails. SC2230: which is non-standard. Use builtin 'command -v' instead.
1 parent 60e00d4 commit 973ea98

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

diagnostics/info.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ _bat_:run() {
5858
_out "$BAT" --version
5959
_out env | grep '^BAT_\|^PAGER='
6060

61-
local cache_dir="$($BAT --cache-dir)"
61+
local cache_dir
62+
cache_dir="$($BAT --cache-dir)"
6263
if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
6364
_print_command "$BAT" "--list-languages"
6465
echo "Found custom syntax set."
@@ -79,8 +80,8 @@ _bat_config_:run() {
7980
_bat_wrapper_:run() {
8081
_bat_wrapper_:detect_wrapper() {
8182
local bat="$1"
82-
if file "$(which "${bat}")" | grep "text executable" &> /dev/null; then
83-
_out_fence cat "$(which "${bat}")"
83+
if file "$(command -v "${bat}")" | grep "text executable" &> /dev/null; then
84+
_out_fence cat "$(command -v "${bat}")"
8485
return
8586
fi
8687

@@ -104,7 +105,8 @@ _bat_wrapper_function_:run() {
104105
fi ;;
105106

106107
*bash* | *zsh*)
107-
local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
108+
local type
109+
type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
108110
if grep 'function' <<< "$type" &> /dev/null; then
109111
_out_fence "$SHELL" --login -i -c "declare -f ${command}"
110112
return

tests/benchmarks/comparison.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

3-
cd "$(dirname "${BASH_SOURCE[0]}")"
3+
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
44

5-
if ! which hyperfine > /dev/null 2>&1; then
5+
if ! command -v hyperfine > /dev/null 2>&1; then
66
echo "'hyperfine' does not seem to be installed."
77
echo "You can get it here: https://github.com/sharkdp/hyperfine"
88
exit 1

tests/benchmarks/run-benchmarks.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

3-
cd "$(dirname "${BASH_SOURCE[0]}")"
3+
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
44

5-
if ! which hyperfine > /dev/null 2>&1; then
5+
if ! command -v hyperfine > /dev/null 2>&1; then
66
echo "'hyperfine' does not seem to be installed."
77
echo "You can get it here: https://github.com/sharkdp/hyperfine"
88
exit 1

tests/syntax-tests/update.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
cd "$(dirname "${BASH_SOURCE[0]}")"
3+
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
44

55
python="python3"
66
if ! command -v python3 &>/dev/null; then python="python"; fi

0 commit comments

Comments
 (0)