Use -+ as arrpath terminator to prevent clearing of destination array, use with caution
authorDominik George <dominik.george@teckids.org>
Sun, 29 Nov 2015 18:30:49 +0000 (18:30 +0000)
committermirabilos <m@mirbsd.org>
Sun, 29 Nov 2015 18:30:49 +0000 (18:30 +0000)
mksh/assoldap.ksh

index c80866f..4b611e5 100644 (file)
@@ -35,21 +35,24 @@ function asso_setldap {
        local arrpath ldapopts x i=0 T dn line value
        set -A arrpath
        while (( $# )); do
-               [[ $1 = -- ]] && break
+               [[ $1 = -- || $1 = -+ ]] && break
                arrpath[i++]=$1
                shift
        done
-       if [[ $1 != -- ]]; then
+       if [[ $1 != -- && $1 != -+ ]]; then
                print -u2 'assoldap.ksh: syntax: asso_setldap arraypath -- ldappath'
                return 255
        fi
+       [[ $1 = -+ ]]; do_free=$?
        shift
        set -A ldapopts -- "$@"
 
-       # just in case, unset the target array and create it as associative
-       asso__lookup 1 "${arrpath[@]}"
-       asso__r_free
-       asso__r_setf $ASSO_AASS
+       if (( do_free )); then
+               # just in case, unset the target array and create it as associative
+               asso__lookup 1 "${arrpath[@]}"
+               asso__r_free
+               asso__r_setf $ASSO_AASS
+       fi
 
        # call ldapsearch with decent output format
        if ! T=$(mktemp -d /tmp/assoldap.XXXXXXXXXX); then