Skip to content

Commit fc3e2b7

Browse files
Merge pull request #17501 from pgier/init-script-minor-fix
Automatic merge from submit-queue (batch tested with PRs 17451, 17501). hack/lib/init.sh: minor shell and readme improvement hack/lib/init.sh: minor shell and readme improvement Use ${BASH_SOURCE[0]} instead of $0 for consistent behavior when script is run directly or using 'source hack/lib/init.sh', and fix regex. Use tabs instead of spaces for indenting in shell scripts. The example in the CONTRIBUTING doc adds the locally built oc binary dir at the end of the PATH. If the user already has oc in the path then this command won't override it. This just changes the example to add the local build to the beginning of the PATH
2 parents 8a19aa1 + 644ad02 commit fc3e2b7

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

CONTRIBUTING.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ $ hack/env make release
137137
In order to make use of the binaries from your shell, add the build output
138138
directory to the `$PATH`:
139139
----
140-
$ export PATH="${PATH}:$( source hack/lib/init.sh; echo "${OS_OUTPUT_BINPATH}/$( os::build::host_platform )/" )"
140+
$ export PATH="$( source hack/lib/init.sh; echo "${OS_OUTPUT_BINPATH}/$( os::build::host_platform )/" ):${PATH}"
141141
----
142142

143143
See more information in https://github.com/openshift/origin/blob/master/HACKING.md#building-on-non-linux-systems[`HACKING.md`]

hack/lib/init.sh

100644100755
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function os::util::absolute_path() {
3030
readonly -f os::util::absolute_path
3131

3232
# find the absolute path to the root of the Origin source tree
33-
init_source="$( dirname "${BASH_SOURCE}" )/../.."
33+
init_source="$( dirname "${BASH_SOURCE[0]}" )/../.."
3434
OS_ROOT="$( os::util::absolute_path "${init_source}" )"
3535
export OS_ROOT
3636
cd "${OS_ROOT}"
@@ -51,14 +51,14 @@ os::log::stacktrace::install
5151
os::util::environment::update_path_var
5252

5353
if [[ -z "${OS_TMP_ENV_SET-}" ]]; then
54-
if [[ "$0" =~ *.sh ]]; then
55-
os::util::environment::setup_tmpdir_vars "$( basename "$0" ".sh" )"
56-
else
57-
os::util::environment::setup_tmpdir_vars "shell"
58-
fi
54+
if [[ "${BASH_SOURCE[0]}" =~ .*\.sh ]]; then
55+
os::util::environment::setup_tmpdir_vars "$( basename "${BASH_SOURCE[0]}" ".sh" )"
56+
else
57+
os::util::environment::setup_tmpdir_vars "shell"
58+
fi
5959
fi
6060

6161
# Allow setting $JUNIT_REPORT to toggle output behavior
6262
if [[ -n "${JUNIT_REPORT:-}" ]]; then
63-
export JUNIT_REPORT_OUTPUT="${LOG_DIR}/raw_test_output.log"
64-
fi
63+
export JUNIT_REPORT_OUTPUT="${LOG_DIR}/raw_test_output.log"
64+
fi

0 commit comments

Comments
 (0)