diff --git a/Formula/beakerlib.rb b/Formula/beakerlib.rb index 4b53d42..e80328e 100644 --- a/Formula/beakerlib.rb +++ b/Formula/beakerlib.rb @@ -11,11 +11,15 @@ class Beakerlib < Formula depends_on "gnu-getopt" end + patch :DATA + def install system "make", "DD=#{prefix}", "install" + orig_getopt="declare GETOPT_CMD=\"getopt\"" + brew_getopt="declare GETOPT_CMD=\"#{Formula["gnu-getopt"].opt_bin}/getopt\"" (prefix.glob "**/*.sh").each do |f| inreplace f, "readlink", "#{Formula["coreutils"].opt_bin}/greadlink", false if OS.mac? - inreplace f, "getopt", "#{Formula["gnu-getopt"].opt_bin}/getopt", false if OS.mac? + inreplace f, orig_getopt, brew_getopt, false if OS.mac? end end @@ -37,3 +41,253 @@ def install assert_match "TESTRESULT_RESULT_STRING=PASS", File.read(testpath/"TestResults") end end + +__END__ +Subject: [PATCH] Alias `getopt` command +--- +Index: src/infrastructure.sh +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/infrastructure.sh b/src/infrastructure.sh +--- a/src/infrastructure.sh (revision 35fc9548c22623146d8c9f6935277ee4ea7f24ab) ++++ b/src/infrastructure.sh (revision a4825d3e5ae9ec5b6723869b828d39b8f6dab0ff) +@@ -28,6 +28,10 @@ + # Boston, MA 02110-1301, USA. + # + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++# Command aliases for compatibilities ++declare GETOPT_CMD="getopt" ++ + echo "${__INTERNAL_SOURCED}" | grep -qF -- " ${BASH_SOURCE} " && return || __INTERNAL_SOURCED+=" ${BASH_SOURCE} " + + : <<'=cut' +@@ -219,7 +223,7 @@ + + rlMount() { + local OPTIONS='' +- local GETOPT=$(getopt -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" ++ local GETOPT=$($GETOPT_CMD -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" + while true; do + case $1 in + --) shift; break; ;; +@@ -288,7 +292,7 @@ + + rlCheckMount() { + local MNTOPTS='' +- local GETOPT=$(getopt -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" ++ local GETOPT=$($GETOPT_CMD -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" + while true; do + case $1 in + --) shift; break; ;; +@@ -383,7 +387,7 @@ + + rlAssertMount() { + local MNTOPTS='' +- local GETOPT=$(getopt -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" ++ local GETOPT=$($GETOPT_CMD -o o: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" + while true; do + case $1 in + --) shift; break; ;; +@@ -461,7 +465,7 @@ + =cut + + rlHash() { +- local GETOPT=$(getopt -o a: -l decode,algorithm:,stdin -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" ++ local GETOPT=$($GETOPT_CMD -o a: -l decode,algorithm:,stdin -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)); eval set -- "$GETOPT" + local decode=0 alg="$rlHashAlgorithm" stdin=0 + while true; do + case $1 in +@@ -637,7 +641,7 @@ + local IFS + + # getopt will cut off first long opt when no short are defined +- OPTS=$(getopt -o "." -l "clean,namespace:,no-missing-ok,missing-ok" -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) ++ OPTS=$($GETOPT_CMD -o "." -l "clean,namespace:,no-missing-ok,missing-ok" -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) + [ $? -ne 0 ] && return 1 + + eval set -- "$OPTS" +@@ -815,7 +819,7 @@ + local IFS + + # getopt will cut off first long opt when no short are defined +- OPTS=$(getopt -o "n:" -l "namespace:" -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) ++ OPTS=$($GETOPT_CMD -o "n:" -l "namespace:" -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) + [ $? -ne 0 ] && return 1 + + eval set -- "$OPTS" +Index: src/logging.sh +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/logging.sh b/src/logging.sh +--- a/src/logging.sh (revision 35fc9548c22623146d8c9f6935277ee4ea7f24ab) ++++ b/src/logging.sh (revision a4825d3e5ae9ec5b6723869b828d39b8f6dab0ff) +@@ -30,6 +30,10 @@ + # Boston, MA 02110-1301, USA. + # + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++# Command aliases for compatibilities ++declare GETOPT_CMD="getopt" ++ + echo "${__INTERNAL_SOURCED}" | grep -qF -- " ${BASH_SOURCE} " && return || __INTERNAL_SOURCED+=" ${BASH_SOURCE} " + + export __INTERNAL_DEFAULT_SUBMIT_LOG=__INTERNAL_FileSubmit +@@ -517,7 +521,7 @@ + =cut + + rlFileSubmit() { +- GETOPT=$(getopt -o s: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) ++ GETOPT=$(GETOPT_CMD -o s: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) + eval set -- "$GETOPT" + + SEPARATOR='-' +Index: src/lsb_release +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/lsb_release b/src/lsb_release +--- a/src/lsb_release (revision 35fc9548c22623146d8c9f6935277ee4ea7f24ab) ++++ b/src/lsb_release (revision a4825d3e5ae9ec5b6723869b828d39b8f6dab0ff) +@@ -62,6 +62,9 @@ + # DECLARATIONS + ############################################################################### + ++# Command aliases for compatibilities ++GETOPT_CMD="getopt" ++ + # This script version + SCRIPTVERSION="2.0" + +@@ -147,17 +150,17 @@ + + # Handles the enhanced args (i.e. --something) + EnhancedGetopt() { +- getopt -T >/dev/null 2>&1 # is getopt the enhanced one ? ++ $GETOPT_CMD -T >/dev/null 2>&1 # is getopt the enhanced one ? + if [ $? = 4 ] + then # Yes, advanced args ALLOWED +- OPT=$(getopt -o acdhirsvp \ ++ OPT=$($GETOPT_CMD -o acdhirsvp \ + --long all,codename,description,help,id,release,short,version,program_version \ + -n 'lsb_release' \ + -- "$@") + else # No, advanced args NOT allowed + # convert (if needed) the enhanced options into basic ones + MYARGS=$(echo "$@" | sed -e "/--/s/-\(-[[:alnum:]]\)[[:alnum:]]*/\1/g") +- OPT=$(getopt -o acdhirsvp \ ++ OPT=$($GETOPT_CMD -o acdhirsvp \ + -n 'lsb_release' \ + -- "$MYARGS") + fi +Index: src/storage.sh +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/storage.sh b/src/storage.sh +--- a/src/storage.sh (revision 35fc9548c22623146d8c9f6935277ee4ea7f24ab) ++++ b/src/storage.sh (revision a4825d3e5ae9ec5b6723869b828d39b8f6dab0ff) +@@ -44,9 +44,10 @@ + __INTERNAL_STORAGE_DEFAULT_NAMESPACE="GENERIC" + + __INTERNAL_ST_OPTION_PARSER=' ++ declare GETOPT_CMD="getopt" + local namespace="$__INTERNAL_STORAGE_DEFAULT_NAMESPACE" + local section="$__INTERNAL_STORAGE_DEFAULT_SECTION" +- local GETOPT=$(getopt -o : -l namespace:,section: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) || return 126 ++ local GETOPT=$($GETOPT_CMD -o : -l namespace:,section: -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) || return 126 + eval set -- "$GETOPT" + while true; do + case $1 in +Index: src/synchronisation.sh +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/synchronisation.sh b/src/synchronisation.sh +--- a/src/synchronisation.sh (revision 35fc9548c22623146d8c9f6935277ee4ea7f24ab) ++++ b/src/synchronisation.sh (revision a4825d3e5ae9ec5b6723869b828d39b8f6dab0ff) +@@ -24,11 +24,16 @@ + # Boston, MA 02110-1301, USA. + # + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++ ++# Command aliases for compatibilities ++declare GETOPT_CMD="getopt" ++ + echo "${__INTERNAL_SOURCED}" | grep -qF -- " ${BASH_SOURCE} " && return || __INTERNAL_SOURCED+=" ${BASH_SOURCE} " + +-getopt -T || ret=$? ++$GETOPT_CMD -T || ret=$? + if [ ${ret:-0} -ne 4 ]; then + echo "ERROR: Non enhanced getopt version detected" 1>&2 ++ echo "getopt command used: $GETOPT_CMD" 1>&2 + exit 1 + fi + +@@ -118,7 +123,7 @@ + shift 1 + + # that is the GNU extended getopt syntax! +- local TEMP=$(getopt -o t:p:m:d:r: -n '$routine_name' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) ++ local TEMP=$($GETOPT_CMD -o t:p:m:d:r: -n '$routine_name' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) + if [[ $? != 0 ]] ; then + rlLogError "$routine_name: Can't parse command options, terminating..." + return 127 +@@ -348,7 +353,7 @@ + local file="" + + # that is the GNU extended getopt syntax! +- local TEMP=$(getopt -o t:p:d: -n 'rlWaitForFile' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) ++ local TEMP=$($GETOPT_CMD -o t:p:d: -n 'rlWaitForFile' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) + if [[ $? != 0 ]] ; then + rlLogError "rlWaitForSocket: Can't parse command options, terminating..." + return 127 +@@ -440,7 +445,7 @@ + local remote=false + + # that is the GNU extended getopt syntax! +- local TEMP=$(getopt -o t:p:d: --longoptions close,remote -n 'rlWaitForSocket' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) ++ local TEMP=$($GETOPT_CMD -o t:p:d: --longoptions close,remote -n 'rlWaitForSocket' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) + if [[ $? != 0 ]] ; then + rlLogError "rlWaitForSocket: Can't parse command options, terminating..." + return 127 +@@ -531,7 +536,7 @@ + #' + rlWait() { + # that is the GNU extended getopt syntax! +- local TEMP=$(getopt -o t:s: -n 'rlWait' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) ++ local TEMP=$($GETOPT_CMD -o t:s: -n 'rlWait' -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) + if [[ $? != 0 ]]; then + rlLogError "rlWait: Can't parse command options, terminating..." + return 128 +Index: src/testing.sh +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/testing.sh b/src/testing.sh +--- a/src/testing.sh (revision 35fc9548c22623146d8c9f6935277ee4ea7f24ab) ++++ b/src/testing.sh (revision a4825d3e5ae9ec5b6723869b828d39b8f6dab0ff) +@@ -1,3 +1,6 @@ ++# Command aliases for compatibilities ++declare GETOPT_CMD="getopt" ++ + echo "${__INTERNAL_SOURCED}" | grep -qF -- " ${BASH_SOURCE} " && return || __INTERNAL_SOURCED+=" ${BASH_SOURCE} " + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # +@@ -759,7 +762,7 @@ + #' + + rlRun() { +- local __INTERNAL_rlRun_GETOPT=$(getopt -o lcts -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) ++ local __INTERNAL_rlRun_GETOPT=$($GETOPT_CMD -o lcts -- "$@" 2> >(while read -r line; do rlLogError "$FUNCNAME: $line"; done)) + eval set -- "$__INTERNAL_rlRun_GETOPT" + + local __INTERNAL_rlRun_DO_LOG=false