Skip to content

Commit 3b5cecc

Browse files
committed
fix usages of which
1 parent 6f7e62a commit 3b5cecc

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

bash-lite.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ if is_zsh_strict; then
162162
else
163163
fn_aliased_exists() { LC_ALL=C alias $1 1>/dev/null 2>&1; }
164164
fi
165+
if fn_defined which; then
166+
: # dbg "'which' has been defined."
167+
else
168+
which() { cmd_exists "$@"; }
169+
fi
170+
which2() { [ "$(whereis -b $1 | awk '{print $2}')" != "" ]; }
165171
fn_name() {
166172
is_zsh && local fn_="${funcstack[2]}"
167173
if [ "$fn_" = "" ]; then

bash.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ if is_zsh_strict; then
358358
else
359359
fn_aliased_exists() { LC_ALL=C alias $1 1>/dev/null 2>&1; }
360360
fi
361+
if fn_defined which; then
362+
: # dbg "'which' has been defined."
363+
else
364+
which() { cmd_exists "$@"; }
365+
fi
366+
which2() { [ "$(whereis -b $1 | awk '{print $2}')" != "" ]; }
361367
fn_name() {
362368
is_zsh && local fn_="${funcstack[2]}"
363369
if [ "$fn_" = "" ]; then
@@ -594,12 +600,12 @@ is_bsd_series() { [[ "$(osid)" == *bsd* ]]; }
594600
#
595601
#
596602
#
597-
lsb_release_cs() { which lsb_release 1>/dev/null 2>&1 && lsb_release -cs; } # focal, ... # = oscodename
598-
uname_kernel() { uname -s; } # Linux
599-
uname_cpu() { uname -p; } # processor: x86_64
600-
uname_mach() { uname -m; } # machine: x86_64, ...
601-
uname_rev() { uname -r; } # kernel-release: 5.8.15-301.fc33.x86_64
602-
uname_ver() { uname -v; } # kernel-version:
603+
lsb_release_cs() { cmd_exists lsb_release && lsb_release -cs; } # focal, ... # = oscodename
604+
uname_kernel() { uname -s; } # Linux
605+
uname_cpu() { uname -p; } # processor: x86_64
606+
uname_mach() { uname -m; } # machine: x86_64, ...
607+
uname_rev() { uname -r; } # kernel-release: 5.8.15-301.fc33.x86_64
608+
uname_ver() { uname -v; } # kernel-version:
603609
lscpu_call() { lscpu $*; }
604610
lshw_cpu() { $SUDO lshw -c cpu; }
605611
i386_amd64() {
@@ -1222,11 +1228,6 @@ subnet_hex() {
12221228
# tip "lanip: '$(lanip)'"
12231229
lanip | tox1
12241230
}
1225-
if fn_defined which; then
1226-
dbg "'which' has been defined."
1227-
else
1228-
which() { whereis "$@"; }
1229-
fi
12301231
if is_darwin; then
12311232
readlinkx() {
12321233
local p="$@"

0 commit comments

Comments
 (0)