#!/bin/bash
# -*- mode: sh; fill-column: 75; tab-width: 8; coding: utf-8-unix -*-
# Gentoo only

ROLE=base
PY_MINOR=3.8

if [ $# -gt 0 -a $1 = --help ] ; then
    /usr/lib/python-exec/python${PY_MINOR}/gemato  "$@"
    exit $?
fi
. /usr/local/bin/proxy_export.bash >/dev/null

declare -a G
if [ $1 = gpg-wrap ] ; then
    G=(${*:1:1} -W ${*:2})
    # need --
    [[ $G =~ '--' ]] && G+=('--')
    [ -f /etc/gnupg/gpgconf.conf ] && G+=(--options /etc/gnupg/gpgconf.conf)
  else
    G=(${*:1:1} ${*:2})
  fi

# The --proxy code is for requests and is wrong: $http_proxy or $https_proxy
#? [ -z "$https_proxy" ] || G=(${G:1:1} --proxy $https_proxy ${G:2})

echo INFO: /usr/lib/python-exec/python${PY_MINOR}/gemato ${G[@]} >> /tmp/G$$.log 2>&1
/usr/lib/python-exec/python${PY_MINOR}/gemato "${G[@]}"  >> /tmp/G$$.log 2>&1
ret=$?
DBUG "$ret"  >> /tmp/G$$.log 2>&1
cat /tmp/G$$.log
exit 0
