On Mon, Dec 27, 2021 at 10:57:55AM +0000, Willenbuecher, Sven / Kuehne + Nagel / Ham MI-GI wrote: > Dear pass maintainers, > > The documentation of the pass program does not say anything about the > supported platforms. I would like to use it on an AIX 7.2 system. I have used > > https://git.zx2c4.com/password-store/snapshot/password-store-1.7.4.tar.xz > > for the installation and applied the attached patches. With these patches > I was able to execute all tests successfully. One issue that I was not > able to overcome refers to > > src/password-store.sh:370: opts="$($GETOPT -o q::c:: -l qrcode::,clip:: > -n "$PROGRAM" -- "$@")" > > The AIX getopt does not know the double colons syntax. I don't know how > to fix that because I have never worked with optional option arguments > and I doubt that I would ever use this kind or proprietary feature.
The readme mentions http://software.frodo.looijaard.name/getopt/ can you use that? The existing OpenBSD platform support indicates that the binary is called "gnugetopt" there, presumably to avoid a name clash. > From: Sven Willenbuecher <[email protected]> > Date: Thu, 23 Dec 2021 11:42:40 +0100 > Subject: [PATCH 2/4] use new VERBOSE_MODE macro variable > > --- > src/password-store.sh | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/src/password-store.sh b/src/password-store.sh > index 6abd8ce..4657145 100755 > --- a/src/password-store.sh > +++ b/src/password-store.sh > @@ -245,7 +245,7 @@ tmpdir() { > GETOPT="getopt" > SHRED="shred -f -z" > BASE64="base64" > -MKDIR="mkdir -p -v" > +VERBOSE_MODE="-v" This patch obsoletes parts of the first patch, it would be easier to read if MKDIR was never introduced > From: Sven Willenbuecher <[email protected]> > Date: Thu, 23 Dec 2021 15:24:36 +0100 > Subject: [PATCH 4/4] implement a LINUX to AIX getopt converter function > > --- > src/platform/aix.sh | 47 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 46 insertions(+), 1 deletion(-) > > diff --git a/src/platform/aix.sh b/src/platform/aix.sh > index 03a3958..93a120f 100644 > --- a/src/platform/aix.sh > +++ b/src/platform/aix.sh > @@ -1 +1,46 @@ > -MKDIR='mkdir -p' > +#!/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:-''}";; I'm not sure if this is safe, what if the input contains characters like $? I'd always quote unless the input is from a set of known-safe characters. > + 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}") You quote twice but eval only once. I don't think that works as intended (unless getopt performs shell expansions?). In practice, it probably works for args without ' or space because of the lazy_quote trick. > + getopt_args="${getopt_args} ${quoted_arg}" > + done > + eval command getopt "${shortopts}" "${getopt_args}" > +) > + > +GETOPT=getopt > +VERBOSE_MODE= > +GREP_COLOR_OPTION= these should be in their respective patches. Perhaps squashing into a larger commit also works here. > -- > 2.20.1
