diff --git a/hack/lib/util/misc.sh b/hack/lib/util/misc.sh index 221bc5aeab36..476c07b77680 100644 --- a/hack/lib/util/misc.sh +++ b/hack/lib/util/misc.sh @@ -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 \ No newline at end of file diff --git a/hack/util.sh b/hack/util.sh index 0e443351de66..30b2d688ea8b 100644 --- a/hack/util.sh +++ b/hack/util.sh @@ -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 \ No newline at end of file +readonly -f os::util::host_platform \ No newline at end of file