# shellcheck shell=dash
___x_cmd_shim__gen_shcode_local_(){
    local varname=; local varpath=; local tmp=
#     if x hascmd bash; then
#         x_="#! /bin/bash
# "
#     else
#         x_="#! /bin/sh
# "
#     fi

    x_="#! /bin/sh
"

    while [ $# -gt 0 ]; do
        case "$1" in
            --) shift; break ;;
            *)
                [ -n "$1" ] || {
                    shift 1
                    continue
                }
                varname=${1%=*}
                varpath=${1#*=}
                if [ -n "$tmp" ]; then
                tmp="$tmp \\
    $varname=\"$varpath\""; shift 1
else
                tmp="$tmp
    $varname=\"$varpath\""; shift 1
fi
    ;;
        esac
    done

    local exec_code="\"$1\"  \"\$@\""
    exec_code="\"\${___X_CMD_SHIM_EXEC:-exec}\" $exec_code"

   if [ -z "$tmp" ]; then
        x_="$x_ $exec_code"
    else
        x_="$x_ $tmp \\
$exec_code"
    fi
}

___x_cmd_shim__gen_shcode_localnull_(){
    x_="${x_}{ "
    while [ $# -gt 0 ]; do
        case "$1" in
            *)
                x_="${x_}
    local $1"
                shift
                ;;
        esac
    done
    x_="${x_}
} 2>/dev/null 1>&2"
}

___x_cmd_shim__gen_shcode_varset_(){
    local varname=; local varpath=; local tmp=
#     if x hascmd bash; then
#         x_="#! /bin/bash
# "
#     else
#         x_="#! /bin/sh
# "
#     fi

    x_="#! /bin/sh
"

    while [ $# -gt 0 ]; do
        case "$1" in
            --) shift; break ;;
            *)
                [ -n "$1" ] || {
                    shift 1
                    continue
                }
                varname=${1%=*}
                varpath=${1#*=}
                if [ -n "$tmp" ]; then
                     tmp="$tmp \\
    $varname=\"\${$varname:-$varpath}\""; shift 1
                else
                    tmp="$tmp
    $varname=\"\${$varname:-$varpath}\""; shift 1
                fi
                ;;
        esac
    done

    local exec_code="\"$1\"  \"\$@\""
    exec_code="\"\${___X_CMD_SHIM_EXEC:-exec}\" $exec_code"

   if [ -z "$tmp" ]; then
        x_="$x_ $exec_code"
    else
        x_="$x_ $tmp \\
$exec_code"
    fi
}
