ast icon indicating copy to clipboard operation
ast copied to clipboard

Substitution failure

Open Sir-Ace-git opened this issue 7 years ago • 3 comments

Description of problem: When running ksh93 script, variable substitution on pipe no longer works properly.

Ksh version: 93u+ 2012-08-01

How reproducible: 100%

Steps to reproduce: #!/bin/ksh93 TEE="/usr/bin/tee -a " LOG="/tmp/null.log" echo "test" |$TEE $LOG

Actual results: test.sh[4]: /usr/bin/tee -a : not found [No such file or directory]

Expected results: test

Additional info: All systems I have seen this on are RHEL 7.6 with current patches. I did not notice this change until today 08/21/2019, when I was asked to troubleshoot the failure of several hundred thousand automated jobs. I am not entirely sure why but this also seems to impact the script's ability to finish. It looks like it will run in blocks, then pause for a long time, then start again. This behaviour wasn't present prior to this week for us, so I assume it has to do something with a recent patch.

Sir-Ace-git avatar Aug 21 '19 21:08 Sir-Ace-git

Works for me using ksh93u+, ksh93v-, and a version built from the current git head. The behavior you are seeing is what would happen if you did

IFS=$'\n'

A practice I recommend, by the way. But if someone recently made that change to all your shell environments that would explain why you're suddenly seeing a problem.

Also, please note that while we're happy to investigate issues of this nature this isn't the place to report problems involving RHEL, SLES, or any other commercial Linux distro for which you are paying for support.

krader1961 avatar Aug 22 '19 03:08 krader1961

To be clear: I can reproduce the O.P.'s problem if I insert IFS='\n' at the top of the reproduction script. That is expected and is one reason the IFS var is such a white hot mess.

krader1961 avatar Aug 22 '19 05:08 krader1961

Ok, so I was testing again today, and that is the cause... I do have an: IFS=' ' set above the affected lines. Apparently it is the only time that i set the IFS separator and don't set it back. I even have the OLDIFS=$IFS set to do so....

So yeah, you pretty much nailed it, but I had to walk away from testing for the evening before I found it myself this morning.
I came to update this but saw your reply, after I had found the exact same thing you described.

As for the distro point, I wasn't sure if it was distro related or not, so in case it wasn't I wanted to report what I found, in case this hadn't been seen before.

Thanks for checking into it, and sorry to send you on a goose-chase.

Sir-Ace-git avatar Aug 22 '19 17:08 Sir-Ace-git