mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-29 13:20:21 +00:00
Simplify locating original tool
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
294a3c2ccb
commit
235799bc23
@ -22,16 +22,13 @@
|
|||||||
# be silenced, e.g. " --version | test ". In this example, "make lib test" will
|
# be silenced, e.g. " --version | test ". In this example, "make lib test" will
|
||||||
# not be silent, but "make lib" will be.
|
# not be silent, but "make lib" will be.
|
||||||
|
|
||||||
# Function to normalise paths
|
# Identify path to original tool. There is an edge-case here where the quiet wrapper is on the path via
|
||||||
get_real_filename() {
|
# a symlink or relative path, but "type -ap" yields the wrapper with it's normalised path. We use
|
||||||
leafname="$(basename "$1")"
|
# the -ef operator to compare paths, to avoid picking the wrapper in this case (to avoid infinitely
|
||||||
( cd $(dirname "$1"); echo "$(pwd)/$leafname" )
|
# recursing).
|
||||||
}
|
while IFS= read -r ORIGINAL_TOOL; do
|
||||||
|
if ! [[ $ORIGINAL_TOOL -ef "$0" ]]; then break; fi
|
||||||
# Normalise path to wrapper script
|
done < <(type -ap -- "$TOOL")
|
||||||
WRAPPER_WITH_PATH=$(get_real_filename "$0")
|
|
||||||
# Identify original tool (compare normalised path to WRAPPER_WITH_PATH to avoid recursively calling the same wrapper script)
|
|
||||||
ORIGINAL_TOOL="$(for p in $(type -ap "$TOOL"); do get_real_filename "$p" ; done | grep -v -Fx "$WRAPPER_WITH_PATH" | head -n1)"
|
|
||||||
|
|
||||||
print_quoted_args() {
|
print_quoted_args() {
|
||||||
# similar to printf '%q' "$@"
|
# similar to printf '%q' "$@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user