Skip to content

Commit

Permalink
Migrated miscellaneous Bash utilities into the hack/lib library
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <[email protected]>
  • Loading branch information
stevekuznetsov committed Oct 25, 2016
1 parent d50865b commit 07633a2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
36 changes: 36 additions & 0 deletions hack/lib/util/misc.sh
Original file line number Diff line number Diff line change
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
18 changes: 0 additions & 18 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -566,24 +566,6 @@ function os::util::host_platform() {
}
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

function os::util::get_object_assert() {
local object=$1
local request=$2
Expand Down

0 comments on commit 07633a2

Please sign in to comment.