Minor improvement in polyfills.
@@ -7,13 +7,15 @@ action() {
[ ! -z "${_law_polyfills_loaded}" ] && return "0"
export _law_polyfills_loaded="1"
-
- # flag that is "1" when on a Mac, empty otherwise
- export _law_on_mac="$( [ "$( uname -s )" = "Darwin" ] && echo "1" || echo "0" )"
+ # boolean flag that is true when on a Mac, false otherwise
+ export _law_on_mac="$( [ "$( uname -s )" = "Darwin" ] && echo "true" || echo "false" )"
+ #
# cross-OS grep
- if [ "${_law_on_mac}" = "1" ]; then
+ #
+
+ if ${_law_on_mac}; then
_law_grep_path="$( which grep 2> /dev/null )"
else
_law_grep_path="$( which --skip-alias --skip-functions grep 2> /dev/null )"
@@ -28,8 +30,11 @@ action() {
[ ! -z "$BASH_VERSION" ] && export -f _law_grep
+ #
# cross-OS grep -Po
- if [ "${_law_on_mac}" = "1" ]; then
+ #
+
+ if ${_law_on_mac}; then
_law_grep_Po() {
perl -nle "print $& if m{$1}" "${@:2}"
}
@@ -40,4 +45,4 @@ action() {
fi
[ ! -z "$BASH_VERSION" ] && export -f _law_grep_Po
}
-action
+action "$@"
