Skip to content

Commit

Permalink
`which' is sometimes an alias, sigh.
Browse files Browse the repository at this point in the history
  • Loading branch information
slewsys committed Dec 23, 2024
1 parent 60dd322 commit c718d7e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@
#
script_name=$(basename $0)

if set +o 2>/dev/null | grep -q 'pipefail$'; then
set -o pipefail
fi

which ()
{
# Red Hat and OpenSUSE define `which' as an alias which isn't
# exported to sub-shells, and though functions are shadowed by
# aliases, at least this should be seen by sub-shells. Since
# `type' is POSIX, and we can reasonably assume this function's
# argument (one of the autotools) is in the command path, it ought
# to serve our purposes, knock on wood.
type "$1" 2>/dev/null |
sed -n '1s,.*is \(/.*\),\1,p' || return $?
}

case "$1" in
-h*|--h*)
echo "Usage: $script_name [-h|--help] [-s|--silent] [maintainer-update-dist]"
Expand Down
16 changes: 16 additions & 0 deletions contrib/call-graph/autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
#
script_name=$(basename $0)

if set +o 2>/dev/null | grep -q 'pipefail$'; then
set -o pipefail
fi

which ()
{
# Red Hat and OpenSUSE define `which' as an alias which isn't
# exported to sub-shells, and though functions are shadowed by
# aliases, at least sub-shells should see this. Since `type' is
# POSIX, and we can reasonably assume its argument (one of the
# autotools) is in the command path, hopefully this is portable
# enough for our purposes, sigh.
type "$1" 2>/dev/null |
sed -n '1s,.*is \(/.*\),\1,p' || return $?
}

case "$1" in
-h*|--h*)
echo "Usage: $script_name [-h|--help] [-s|--silent] [maintainer-update-dist]"
Expand Down
16 changes: 16 additions & 0 deletions contrib/prdg/autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
#
script_name=$(basename $0)

if set +o 2>/dev/null | grep -q 'pipefail$'; then
set -o pipefail
fi

which ()
{
# Red Hat and OpenSUSE define `which' as an alias which isn't
# exported to sub-shells, and though functions are shadowed by
# aliases, at least sub-shells should see this. Since `type' is
# POSIX, and we can reasonably assume its argument (one of the
# autotools) is in the command path, hopefully this is portable
# enough for our purposes, sigh.
type "$1" 2>/dev/null |
sed -n '1s,.*is \(/.*\),\1,p' || return $?
}

case "$1" in
-h*|--h*)
echo "Usage: $script_name [-h|--help] [-s|--silent] [maintainer-update-dist]"
Expand Down

0 comments on commit c718d7e

Please sign in to comment.