[PATCH v2 2/2] implement a LINUX to AIX getopt converter function

Rene Kita mail at rkta.de
Wed Dec 29 16:45:43 UTC 2021


On Wed, Dec 29, 2021 at 01:38:31PM +0100, Sven Willenbuecher wrote:
> ---
>  src/platform/aix.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/src/platform/aix.sh b/src/platform/aix.sh
> index e94ee73..93a120f 100644
> --- a/src/platform/aix.sh
> +++ b/src/platform/aix.sh
> @@ -1,2 +1,46 @@
> +#!/usr/bin/sh
> +
> +quote() (
> +  arg=$1
> +
> +  quoted_arg="'"
> +  while true; do
> +    case ${arg} in
> +      *\'* ) quoted_arg=${quoted_arg}${arg%%\'*}"'\''"
> +             arg=${arg#*\'};;
> +         * ) break;;
> +    esac
> +  done
> +  [ -z "${arg}" ] || quoted_arg=${quoted_arg}${arg}
> +  quoted_arg=${quoted_arg}"'"
> +
> +  printf %s "${quoted_arg}"
> +)
> +
> +quote_lazy() {
> +  case $1 in
> +    *[\ \']* ) quote "$1";;
> +         *   ) printf %s "${1:-''}";;
> +  esac
> +}
> +
> +getopt() (
> +  while getopts :ahl:n:o:qQs:uTV opt; do
> +    case ${opt} in
> +      o ) shortopts=$OPTARG;;
> +      * ) true;;
> +    esac
> +  done
> +  getopt_args=
> +  shift $((OPTIND - 1))
> +  for arg; do
> +    quoted_arg=$(quote_lazy "${arg}")
> +    quoted_arg=$(quote_lazy "${quoted_arg}")
> +    getopt_args="${getopt_args} ${quoted_arg}"
> +  done
> +  eval command getopt "${shortopts}" "${getopt_args}"
> +)
> +
> +GETOPT=getopt
>  VERBOSE_MODE=
>  GREP_COLOR_OPTION=
> -- 
> 2.31.1
> 

Shouldn't this use the same indentation style as all other files?

Rene


More information about the Password-Store mailing list