*Synopsis*: *ksh93* bug in pattern matching CR 6766246 changed on Jan 16 2009 by <User 1-5Q-3253>
=== Field ============ === New Value ============= === Old Value ============= Integrated in Build snv_106 Status 10-Fix Delivered 8-Fix Available ====================== =========================== =========================== *Change Request ID*: 6766246 *Synopsis*: *ksh93* bug in pattern matching Product: solaris Category: shell Subcategory: korn93 Type: Defect Subtype: Status: 10-Fix Delivered Substatus: Priority: 3-Medium Introduced In Release: solaris_nevada Introduced In Build: snv_72 Responsible Engineer: <User 1-5Q-5151> Keywords: opensolaris, oss-request, oss-sponsor === *Description* ============================================================ Category shell Sub-Category bourne Description This was already reported as http://www.opensolaris.org/jive/thread.jspa?threadID=80967 The bootstrap script of pkgsrc contains this code checkarg_sane_absolute_path() { case "$1" in "") ;; # the default value will be used. *[!-A-Za-z0-9_./]*) die "ERROR: Invalid characters in path $1 (from $2)." ;; /*) ;; *) die "ERROR: The argument to $2 must be an absolute path." ;; esac } It turns out, the leading "!" in the pattern is not interpreted as negation, and the first "-" not as a literal. Instead the character range "! to A" is constructed. Paths containing "%" or "@" are accepted, but paths containing "-" are rejected. Note that this interpretation makes the whole pattern syntactically wrong, which isn't noticed either. Frequency Always Regression Solaris 10 Steps to Reproduce run example below Expected Result strings containing a "-" should be accepted, strings containing a "@" should be rejected Actual Result strings containing a "-" are rejected, strings containing a "@" are accepted Error Message(s) Test Case #!/bin/sh case "$1" in *[!-A-Za-z0-9_./]*) echo invalid characters used in $1 ;; *) echo only valid characters used in $1 ;; esac Workaround The pattern "*[!A-Za-z0-9_./-]*" (i.e. shifting the dash to the end) works as expected. Submitter wants to work on bug No Additional configuration information *** (#1 of 1): 2008-10-31 17:54:10 GMT+00:00 <User 1-F4SZV> === *Public Comments* ======================================================== Since the post on the forums that was posted to says "I am using OpenSolaris 2008.05.", assigning this to shell/korn93, not shell/bourne. (2008.05 /bin/sh is ksh93.) *** (#1 of 2): 2008-11-04 04:09:56 GMT+00:00 alan.coopersmith at sun.com *** Last Edit: 2008-11-04 15:23:49 GMT+00:00 alan.coopersmith at sun.com Glenn Fowler has responded to the bug report on the ksh93-integration-discuss list/forum on opensolaris.org with: thanks for the report its a coding bug exposed by character class ranges in non-C locales as a temporary workaround, the matching should work as expected for LC_ALL=C the fix has been posted in the official 2008-11-04 source tarballs at http://www.research.att.com/sw/download/ [Thread at http://www.opensolaris.org/jive/thread.jspa?threadID=81453&tstart=0 ] *** (#2 of 2): 2008-11-04 15:23:49 GMT+00:00 alan.coopersmith at sun.com === *Workaround* ============================================================= === *Additional Details* ===================================================== Targeted Release: solaris_nevada Commit To Fix In Build: snv_106 Fixed In Build: snv_106 Integrated In Build: snv_106 Verified In Build: See Also: 6437624, 6619428 Duplicate of: Hooks: Hook1: Hook2: Hook3: Hook4: Hook5: <email address omitted> Hook6: <email address omitted> Program Management: Root Cause: Other - see Research Activity Fix Affects Documentation: No Fix Affects Localization: No === *History* ================================================================ Date Submitted: 2008-10-31 17:54:09 GMT+00:00 Submitted By: <User 1-F4SZV> Status Changed Date Updated Updated By 6-Fix Understood 2008-11-04 22:23:05 GMT+00:00 <User 1-5Q-5151> 7-Fix in Progress 2008-12-22 08:28:42 GMT+00:00 <User 1-5Q-5151> 8-Fix Available 2008-12-27 23:21:55 GMT+00:00 <User 1-5HNZ8F> 10-Fix Delivered 2009-01-16 03:27:19 GMT+00:00 <User 1-5Q-3253> === *Service Request* ======================================================== Impact: Significant Functionality: Secondary Severity: 3 Product Name: solaris Product Release: solaris_nevada Product Build: snv_86 Operating System: solaris_nevada Hardware: x86 Submitted Date: 2008-10-31 17:54:10 GMT+00:00 === *Multiple Release (MR) Cluster* - 0 ======================================