Pass KRB5CCNAME through to the failsafe kinit only if -c wasn't used.
unset cache ccname default ng
function kinit() {
- [ -n "$KRB5CCNAME" ] && krb5ccname="env KRB5CCNAME=$KRB5CCNAME"
- ( builtin cd /; exec -c $krb5ccname kinit ${1+"$@"} )
+ local args=
+ local krb5ccname=
+ if [ -n "$KRB5CCNAME" ]; then
+ args="$@"
+ [ "${args/-c /}" = "$args" ] && krb5ccname="-c $KRB5CCNAME"
+ fi
+ ( builtin cd /; exec -c kinit $krb5ccname ${1+"$@"} )
}