Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 085a34b9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix b with zsh."

parents 46ee66c0 4ed082f6
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -1866,20 +1866,29 @@ function b()
        # command. (build, test, run, ect) If the --config was added at the end, it wouldn't work with commands like:
        # b run //foo -- --args-for-foo
        local config_set=0
        local bazel_args_with_config=""

        # Represent the args as an array, not a string.
        local bazel_args_with_config=()
        for arg in $bazel_args; do
            if [[ $arg == "--" && $config_set -ne 1 ]]; # if we find --, insert config argument here
            then
                bazel_args_with_config+="--config=bp2build -- "
                bazel_args_with_config+=("--config=bp2build -- ")
                config_set=1
            else
                bazel_args_with_config+="$arg "
                bazel_args_with_config+=("$arg ")
            fi
        done
        if [[ $config_set -ne 1 ]]; then
            bazel_args_with_config+="--config=bp2build "
            bazel_args_with_config+=("--config=bp2build ")
        fi

        if [ -n "$ZSH_VERSION" ]; then
          # zsh breaks posix by not doing string-splitting on unquoted args
          # by default. Enable the compatibility option.
          setopt shwordsplit
        fi
        bazel $bazel_args_with_config
        # Call Bazel.
        bazel ${bazel_args_with_config[@]}
    fi
)