Please isolate that problem to a simpler case, e.g. using just su and some simple scripts. No trivial case I tried had a problem like you're describing. It's hard to know from that trace why su decided to fail. However, I do now know the password you typed. :-)