ksh function problem with backticks
Issue
-
Application scripts are working fine with RHEL5.4 (ksh-20080202-14.el5), it doesn't work on RHEL5.5-5.9 and RHEl6.1-4 version of
ksh. -
In the later
kshversion it works only when we add theevalbuiltin function. It also works if there is no backticks on the output file ofdatecommand. -
In the script reproducer, we are expecting a
[[ success == success ]]contrary to[[ '' == success ]]as shown in the debugging output. -
Reproducer script:
$ cat /tmp/jj.sh
#!/bin/ksh
a_func ()
{
date > /tmp/example.`date +%Y`
print "success"
}
if [[ `a_func` = success ]]; then
echo "success."
else
echo "failed."
fi
- On RHEL6:
$ rpm -qa |grep ksh
ksh-20100621-19.el6.x86_64
$ ksh -x /tmp/jj.sh
+ a_func
+ date
+ + date +%Y
1> /tmp/example.2013
+ print success
+ [[ '' == success ]]
+ echo failed.
failed.
- On RHEL5.4:
$ rpm -qa |grep ksh
ksh-20080202-14.el5
$ ksh -x /tmp/jj.sh
+ a_func
+ date
+ + date +%Y
1> /tmp/example.2013
+ print success
+ [[ success == success ]]
+ echo success.
success.
Environment
- Red Hat Enterprise Linux (RHEL) 6.4
- Red Hat Enterprise Linux (RHEL) 5.5-5.9
- ksh-20100621-12.el5
- ksh-20100621-19.el6
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.