From 5367495b4ff9498f798cd109d2acc83fdc40991d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 19:26:41 +0000 Subject: [PATCH 1/3] Initial plan From 3d19207134fb11f95bfd0e28c1a9015e8ee03932 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 19:31:18 +0000 Subject: [PATCH 2/3] Rewrite cli/builbo arg parsing: GNU getopt with getopts fallback for portability Co-authored-by: obnoxxx <8081179+obnoxxx@users.noreply.github.com> --- cli/builbo | 155 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 53 deletions(-) diff --git a/cli/builbo b/cli/builbo index 1ec40a7..ccd2cae 100755 --- a/cli/builbo +++ b/cli/builbo @@ -2,20 +2,18 @@ function detect_container_command() { - if [ -z "${CONTAINER_CMD}" ]; then CONTAINER_CMD="$(podman version > /dev/null 2>&1 && echo podman)" fi if [ -z "${CONTAINER_CMD}" ]; then CONTAINER_CMD="$(docker version > /dev/null 2>&1 && echo docker)" - fi } -# default values for ccommand line options: +# default values for command line options: LANG=c REGISTRY=quay.io CONTAINER_CMD="" @@ -25,7 +23,7 @@ fi DEPS="" DEFAULT_ACTION="help" ACTION="$DEFAULT_ACTION" - # action that was explicxitly set from the command line: + # action that was explicitly set from the command line: EXPLICIT_ACTION="" # shell for interactive use: I_SHELL="bash" @@ -38,6 +36,14 @@ if [ -z "$CONTAINER_CMD" ]; then exit 1 fi +# Detect whether GNU getopt is available. +# GNU getopt returns exit code 4 when called with --test; BSD getopt does not. +HAS_GNU_GETOPT=false +getopt --test > /dev/null 2>&1 +if [ $? -eq 4 ]; then + HAS_GNU_GETOPT=true +fi + function usage() { >&2 cat <&2 + echo " Install GNU getopt for long option support (e.g. brew install gnu-getopt on macOS)." >&2 + + # Error on any long options passed by the user. + # Track value-consuming short options so their values are not mistaken for long options. + skip_next=false + for arg in "$@"; do + if $skip_next; then + skip_next=false + continue + fi + if [[ "$arg" == --?* ]]; then + echo "error: long option '$arg' is not supported without GNU getopt." >&2 + echo " Please use the equivalent short option, or install GNU getopt." >&2 + usage + exit 1 + fi + # Short options that consume the next argument (from optstring: l:r:c:o:n:s:d:) + if [[ "$arg" =~ ^-[lrconsd]$ ]]; then + skip_next=true + fi + done + + while getopts "$optstring" opt; do + case "$opt" in + l) LANG="$OPTARG" ;; + r) REGISTRY="$OPTARG" ;; + c) CONTAINER_CMD="$OPTARG";; + o) OS="$OPTARG" ;; + n) NAMESPACE="$OPTARG" ;; + s) BUILD_CMD="$OPTARG" ;; + d) DEPS="$OPTARG" ;; + h) set_action "help" ;; + b) set_action "build" ;; + t) set_action "test" ;; + e) set_action "enter" ;; + *) + echo "error: invalid args." + usage + exit 1 + ;; + esac + done + shift $((OPTIND - 1)) fi -# processing parsed args - -eval set -- "$parsed_args" -while : -do - case "$1" in - -l | --lang) LANG="$2" ; shift 2 ;; - -r | --registry) REGISTRY="$2" ; shift 2 ;; - -c | --container-cmd) CONTAINER_CMD="$2"; shift 2 ;; - -o | --os) OS="$2"; shift 2 ;; - -n | --registry-namespace) NAMESPACE="$2" ; shift 2 ;; - -s | --build-script) BUILD_CMD="$2" ; shift 2 ;; - -d | --deps) DEPS="$2"; shift 2 ;; - -h | --help) set_action "help" ; shift ;; - -b| --build) set_action "build" ; shift ;; - -t| --test) set_action "test" ; shift ;; - -e|--enter) set_action "enter" ; shift ;; - - - # -- means end of args. ignore and stop processing. - --) shift ; break ;; - *) echo "Unexpected option $1. - this should not happen." - # this should have been caught above with args_valid - usage - exit 1 - ;; - esac -done - # done processing args From cdfabe916c86ec0ad830655c1570820b4bdd7151 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 18:15:22 +0000 Subject: [PATCH 3/3] Revert cli/builbo to original state - superseded by PR #24 Co-authored-by: obnoxxx <8081179+obnoxxx@users.noreply.github.com> --- cli/builbo | 155 ++++++++++++++++++----------------------------------- 1 file changed, 53 insertions(+), 102 deletions(-) diff --git a/cli/builbo b/cli/builbo index ccd2cae..1ec40a7 100755 --- a/cli/builbo +++ b/cli/builbo @@ -2,18 +2,20 @@ function detect_container_command() { + if [ -z "${CONTAINER_CMD}" ]; then CONTAINER_CMD="$(podman version > /dev/null 2>&1 && echo podman)" fi if [ -z "${CONTAINER_CMD}" ]; then CONTAINER_CMD="$(docker version > /dev/null 2>&1 && echo docker)" + fi } -# default values for command line options: +# default values for ccommand line options: LANG=c REGISTRY=quay.io CONTAINER_CMD="" @@ -23,7 +25,7 @@ fi DEPS="" DEFAULT_ACTION="help" ACTION="$DEFAULT_ACTION" - # action that was explicitly set from the command line: + # action that was explicxitly set from the command line: EXPLICIT_ACTION="" # shell for interactive use: I_SHELL="bash" @@ -36,14 +38,6 @@ if [ -z "$CONTAINER_CMD" ]; then exit 1 fi -# Detect whether GNU getopt is available. -# GNU getopt returns exit code 4 when called with --test; BSD getopt does not. -HAS_GNU_GETOPT=false -getopt --test > /dev/null 2>&1 -if [ $? -eq 4 ]; then - HAS_GNU_GETOPT=true -fi - function usage() { >&2 cat <&2 - echo " Install GNU getopt for long option support (e.g. brew install gnu-getopt on macOS)." >&2 - - # Error on any long options passed by the user. - # Track value-consuming short options so their values are not mistaken for long options. - skip_next=false - for arg in "$@"; do - if $skip_next; then - skip_next=false - continue - fi - if [[ "$arg" == --?* ]]; then - echo "error: long option '$arg' is not supported without GNU getopt." >&2 - echo " Please use the equivalent short option, or install GNU getopt." >&2 - usage - exit 1 - fi - # Short options that consume the next argument (from optstring: l:r:c:o:n:s:d:) - if [[ "$arg" =~ ^-[lrconsd]$ ]]; then - skip_next=true - fi - done - - while getopts "$optstring" opt; do - case "$opt" in - l) LANG="$OPTARG" ;; - r) REGISTRY="$OPTARG" ;; - c) CONTAINER_CMD="$OPTARG";; - o) OS="$OPTARG" ;; - n) NAMESPACE="$OPTARG" ;; - s) BUILD_CMD="$OPTARG" ;; - d) DEPS="$OPTARG" ;; - h) set_action "help" ;; - b) set_action "build" ;; - t) set_action "test" ;; - e) set_action "enter" ;; - *) - echo "error: invalid args." - usage - exit 1 - ;; - esac - done - shift $((OPTIND - 1)) +if [ "$args_valid" != "0" ]; then + echo "error:invalid args." + usage + exit 1 fi +# processing parsed args + +eval set -- "$parsed_args" +while : +do + case "$1" in + -l | --lang) LANG="$2" ; shift 2 ;; + -r | --registry) REGISTRY="$2" ; shift 2 ;; + -c | --container-cmd) CONTAINER_CMD="$2"; shift 2 ;; + -o | --os) OS="$2"; shift 2 ;; + -n | --registry-namespace) NAMESPACE="$2" ; shift 2 ;; + -s | --build-script) BUILD_CMD="$2" ; shift 2 ;; + -d | --deps) DEPS="$2"; shift 2 ;; + -h | --help) set_action "help" ; shift ;; + -b| --build) set_action "build" ; shift ;; + -t| --test) set_action "test" ; shift ;; + -e|--enter) set_action "enter" ; shift ;; + + + # -- means end of args. ignore and stop processing. + --) shift ; break ;; + *) echo "Unexpected option $1. - this should not happen." + # this should have been caught above with args_valid + usage + exit 1 + ;; + esac +done + # done processing args