I’ve found following function in our old scripts:
f() { # < files list
typeset file
cat - > $TMPFILE # Bug in KSH
while read -r file
do
process $file
done < $TMPFILE
}
Does anyone know this bug in KSH?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Apparently f() is a filter function, i.e. you are supposed to use it in a pipe like so
Where you’d expect
read -rto read stdin just fine, e.g. when doingapparently, there is (was?) a bug in (certain) ksh (version(s)) that prevented the same to work from a function:
I foun two bugs that could be it, depending mostly on your platform:
There are possibly (many) more historical bugs that could apply, and I stopped searching because I don’t know anything about your platform, or indeed the platform the script was designed for.
So instead there has been a workaround involving writing the stdin to a temporary file, and reading from that. Note that
$$TMPFILE, probably instead of$TMPFILE?) in your sample (unless there is one more feature of KSH I wasn’t aware of,$$expands to the current process Id)).