optimise one tr(1) away by telling read the line delimiter to use
authorThorsten Glaser <tg@mirbsd.org>
Sun, 3 Nov 2013 01:21:48 +0000 (01:21 +0000)
committerThorsten Glaser <tg@mirbsd.org>
Sun, 3 Nov 2013 01:22:27 +0000 (01:22 +0000)
inspired by IRC question by alip

mksh/assoldap.ksh

index 5854598..aa788a0 100644 (file)
@@ -52,7 +52,7 @@ function asso_setldap {
                return 255
        fi
        (ldapsearch -xLLL "${ldapopts[@]}"; echo $? >"$T/err") | \
-           tr '\n' $'\a' | sed -e $'s/\a //g' | tr $'\a' '\n' >"$T/out"
+           tr '\n' $'\a' | sed -e $'s/\a //g' >"$T/out"
        i=$(<"$T/err")
        if (( i )); then
                print -u2 'assoldap.ksh: ldapsearch returned error'
@@ -66,7 +66,7 @@ function asso_setldap {
        fi
 
        # parse LDIF (without linewraps)
-       while IFS= read -r line; do
+       while IFS= read -d $'\a' -r line; do
                if [[ -z $line ]]; then
                        dn=
                        continue