Bug 802565 - Tilda expansion failing in ksh
Summary: Tilda expansion failing in ksh
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: ksh
Version: 5.8
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: rc
: ---
Assignee: Michal Hlavinka
QA Contact: Martin Kyral
URL:
Whiteboard:
Depends On:
Blocks: 727267 805459
TreeView+ depends on / blocked
 
Reported: 2012-03-12 21:09 UTC by Peter Fales
Modified: 2018-11-27 20:22 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1264077 (view as bug list)
Environment:
Last Closed: 2013-01-08 07:21:46 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:0042 0 normal SHIPPED_LIVE ksh bug fix update 2013-01-07 15:28:20 UTC

Description Peter Fales 2012-03-12 21:09:23 UTC
Description of problem:

Tilda expansion fails to take place under certain conditions

Version-Release number of selected component (if applicable):

ksh-20100621-5.el5


How reproducible:

Always


Steps to Reproduce:
1.  create the following script:  (here ~root/bin/date is just a copy of 
    bin/date)

    #!/usr/bin/ksh
    echo $(~root/bin/date)
    ~root/bin/date

2.  Execute the script

Actual results:

The first line prints the date, the second line prints an error because ~root is not getting expanded:

/tmp/ksh.bug[3]: ~root/bin/date: not found [No such file or directory]


Expected results:

Both lines should print the date.




Additional info:

If the second line is commented out, then tilda expansion correctly takes place in the third line and the date is printed.


RHEL 5.8 has ksh93t+.  The bug is also showing up in ksh93u+ and AT&T gave me this patch for 93u+:

--- .../sh/macro.c      Tue Feb  7 09:56:20 2012
+++ sh/macro.c  Fri Mar  9 15:58:54 2012
@@ -2700,7 +2700,12 @@
        if(!logins_tree)
                logins_tree = dtopen(&_Nvdisc,Dtbag);
        if(np=nv_search(string,logins_tree,NV_ADD))
+       {
+               c = shp->subshell;
+               shp->subshell = 0;
                nv_putval(np, pw->pw_dir,0);
+               shp->subshell = c;
+       }
        return(pw->pw_dir);
 }

Comment 1 Michal Hlavinka 2012-03-13 09:30:47 UTC
Reproducible and I can confirm that patch fixes this issue.

Modified reproducer:
#!/bin/ksh
cd ${HOME}
TMPDIR=$(mktemp -d test-XXXXXX)
cp /bin/echo ${HOME}/${TMPDIR}/echo
if [ "$(~${USER}/${TMPDIR}/echo OK)$(~${USER}/${TMPDIR}/echo OK)$(~${USER}/${TMPDIR}/echo OK)" = OKOKOK ];
then
  echo "bug fixed"
  rc=0
else
  echo "bug present"
  rc=1
fi
rm -rf ${TMPDIR}
exit $rc

Comment 13 errata-xmlrpc 2013-01-08 07:21:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0042.html


Note You need to log in before you can comment on or make changes to this bug.