From e54965b0545beb04aeccb9eb2bab96f29a8140a1 Mon Sep 17 00:00:00 2001 From: "bazel.build machine account" <15028808+bazel-io@users.noreply.github.com> Date: Fri, 19 Jan 2024 12:08:15 +0100 Subject: [PATCH] [7.1.0] Replaced usage of rev with awk in bash runfiles (#20934) Closes #20885. Commit https://github.com/bazelbuild/bazel/commit/9ae9d1d596cf6dbaedceb86bba9ed89dde68702e PiperOrigin-RevId: 599442183 Change-Id: I4d546ebebeb9007632e51f1ec000bb2332f19cb6 Co-authored-by: Nikhil Kalige --- tools/bash/runfiles/runfiles.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bash/runfiles/runfiles.bash b/tools/bash/runfiles/runfiles.bash index c8afe3efde82cf..6e541090587235 100644 --- a/tools/bash/runfiles/runfiles.bash +++ b/tools/bash/runfiles/runfiles.bash @@ -253,7 +253,7 @@ function runfiles_current_repository() { echo >&2 "ERROR[runfiles.bash]: runfiles_current_repository($idx): ($normalized_caller_path) is not the target of an entry in the runfiles manifest ($RUNFILES_MANIFEST_FILE)" fi # The binary may also be run directly from bazel-bin or bazel-out. - local -r repository=$(echo "$normalized_caller_path" | __runfiles_maybe_grep -E -o '(^|/)(bazel-out/[^/]+/bin|bazel-bin)/external/[^/]+/' | tail -1 | rev | cut -d / -f 2 | rev) + local -r repository=$(echo "$normalized_caller_path" | __runfiles_maybe_grep -E -o '(^|/)(bazel-out/[^/]+/bin|bazel-bin)/external/[^/]+/' | tail -1 | awk -F/ '{print $(NF-1)}') if [[ -n "$repository" ]]; then if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then echo >&2 "INFO[runfiles.bash]: runfiles_current_repository($idx): ($normalized_caller_path) lies in repository ($repository) (parsed exec path)" @@ -295,7 +295,7 @@ function runfiles_current_repository() { # is the sh_binary entrypoint. Parse its path under the execroot, using the last match to # allow for nested execroots (e.g. in Bazel integration tests). The binary may also be run # directly from bazel-bin. - local -r repository=$(echo "$normalized_caller_path" | __runfiles_maybe_grep -E -o '(^|/)(bazel-out/[^/]+/bin|bazel-bin)/external/[^/]+/' | tail -1 | rev | cut -d / -f 2 | rev) + local -r repository=$(echo "$normalized_caller_path" | __runfiles_maybe_grep -E -o '(^|/)(bazel-out/[^/]+/bin|bazel-bin)/external/[^/]+/' | tail -1 | awk -F/ '{print $(NF-1)}') if [[ -n "$repository" ]]; then if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then echo >&2 "INFO[runfiles.bash]: runfiles_current_repository($idx): ($normalized_caller_path) lies in repository ($repository) (parsed exec path)"