Skip to content

Commit

Permalink
Merge pull request #11535 from stevekuznetsov/skuznets/migrate-utilities
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Oct 26, 2016
2 parents 5dc2155 + 7168fe6 commit 38c9545
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
36 changes: 36 additions & 0 deletions hack/lib/util/misc.sh
Expand Up @@ -129,3 +129,39 @@ function os::util::find-go-binary() {
done
}
readonly -f os::util::find-go-binary

# os::util::sed attempts to make our Bash scripts agnostic to the platform
# on which they run `sed` by glossing over a discrepancy in flag use in GNU.
#
# Globals:
# None
# Arguments:
# - all: arguments to pass to `sed -i`
# Return:
# None
function os::util::sed() {
if LANG=C sed --help 2>&1 | grep -q "GNU sed"; then
sed -i'' "$@"
else
sed -i '' "$@"
fi
}
readonly -f os::util::sed

# os::util::base64decode attempts to make our Bash scripts agnostic to the platform
# on which they run `base64decode` by glossing over a discrepancy in flag use in GNU.
#
# Globals:
# None
# Arguments:
# - all: arguments to pass to `base64decode`
# Return:
# None
function os::util::base64decode() {
if [[ "$(go env GOHOSTOS)" == "darwin" ]]; then
base64 -D "$@"
else
base64 -d "$@"
fi
}
readonly -f os::util::base64decode
20 changes: 1 addition & 19 deletions hack/util.sh
Expand Up @@ -543,22 +543,4 @@ readonly -f find_files
function os::util::host_platform() {
echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"
}
readonly -f os::util::host_platform

function os::util::sed() {
if LANG=C sed --help 2>&1 | grep -qs "GNU sed"; then
sed -i'' "$@"
else
sed -i '' "$@"
fi
}
readonly -f os::util::sed

function os::util::base64decode() {
if [[ "$(go env GOHOSTOS)" == "darwin" ]]; then
base64 -D $@
else
base64 -d $@
fi
}
readonly -f os::util::base64decode
readonly -f os::util::host_platform

0 comments on commit 38c9545

Please sign in to comment.