Bug 407191

Summary: string tests in ksh do not work properly
Product: [openSUSE] openSUSE 11.0 Reporter: John Young <j.e.young>
Component: OtherAssignee: Dr. Werner Fink <werner>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: Final   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 11.0   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description John Young 2008-07-08 15:56:42 UTC
How to reproduce the problem:

If you run the following short test script with /bin/pdksh, it works 
correctly.  If you run it with /bin/ksh (being a link to 
/lib64/ast/bin/ksh), the output is incorrect:

#! /bin/ksh
cmdname="job"
prod="foo"
[[ $cmdname = $prod[1-9][0-9]* ]] && {
   echo test 1 passed
}
cmdname="foo"
[[ $cmdname = $prod[1-9][0-9]* ]] && {
   echo test 2 passed
}
cmdname="foo2007"
[[ $cmdname = $prod[1-9][0-9]* ]] && {
   echo test 3 passed
}

linuxhost{username}% ./foo.ksh 
test 1 passed
test 2 passed
test 3 passed

It really should be:

linuxhost{username}% ./foo.ksh 
test 3 passed

(Sorry -- this was the case under 10.3 also, but I thought you all would 
find it.  I probably should have reported it earlier. )
Comment 1 Dr. Werner Fink 2008-07-10 15:38:09 UTC
Please report this *upstream* as I'm not the author of the ksh.
I'm only the maintainer. Beside the pdksh is not compatible with
the original ksh (here ksh93) ... do you have ever tried

 #! /bin/ksh
 cmdname="job"
 prod="foo"
 [[ $cmdname =~ ${prod}[1-9][0-9]* ]] && {
    echo test 1 passed
 }
 cmdname="foo"
 [[ $cmdname =~ ${prod}[1-9][0-9]* ]] && {
    echo test 2 passed
 }
 cmdname="foo2007"
 [[ $cmdname =~ ${prod}[1-9][0-9]* ]] && {
    echo test 3 passed
 }