diff --git a/tools/bash/runfiles/runfiles.bash b/tools/bash/runfiles/runfiles.bash index a574f4c750d76b..8e1f9441a11499 100644 --- a/tools/bash/runfiles/runfiles.bash +++ b/tools/bash/runfiles/runfiles.bash @@ -372,10 +372,10 @@ function runfiles_rlocation_checked() { local escaped=false fi # The extra space below is added because cut counts from 1. - local trim_length=$(echo -n "$search_prefix " | wc -c) + local trim_length=$(echo -n "$search_prefix " | wc -c | tr -d ' ') # Escape the search prefix for use in the grep regex below *after* # determining the trim length. - local result=$(__runfiles_maybe_grep -m1 "^$(echo -n "$search_prefix" | sed 's/[.[\*^$]/\\&/g') " "${RUNFILES_MANIFEST_FILE}" | cut -b ${trim_length}-) + local result=$(__runfiles_maybe_grep -m1 "^$(echo -n "$search_prefix" | sed 's/[.[\*^$]/\\&/g') " "${RUNFILES_MANIFEST_FILE}" | cut -b "${trim_length}-") if [[ -z "$result" ]]; then # If path references a runfile that lies under a directory that itself # is a runfile, then only the directory is listed in the manifest. Look