Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added the fix for script for not being able to use in script source path #218

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/util/deploy-hostpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
set -e
set -o pipefail

BASE_DIR=$(dirname "$0")
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need BASH_SOURCE here? Why not just $0?

Also, why the output redirection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well both BASH_SOURCE and $0 would serve the same purpose here just using the BASH_SOURCE in bash script is better even if it is sourced

And for output redirection, sometimes cd prints something to stdout, in the case where a CDPATH is set and even an error can be printed. So to be safe, there is the stdout redirection to dev null and stderr to stdout

To cover CDPATH weird cases, we can even follow to unset CDPATH at the begining and not use this redirection but still it will be changing user's config

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well both BASH_SOURCE and $0 would serve the same purpose here just using the BASH_SOURCE in bash script is better even if it is sourced

I think it is better to not depend on bash features unnecessarily, because then a conversion to a non-Bash script becomes easier. Currently pipefail is the only bashism that I am aware of, and even that may not be necessary.

And for output redirection, sometimes cd prints something to stdout

During normal operation? That's very unexpected.

in the case where a CDPATH is set and even an error can be printed.

If an error is printed, presumably the return code is non-zero, BASE_DIR is unset and everything fails. We want to see the error message of cd in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohkay, right. we can depend on pipefail I can ignore the output redirection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


# If set, the following env variables override image registry and/or tag for each of the images.
# They are named after the image name, with hyphen replaced by underscore and in upper case.
Expand Down