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/

On Mon, 3 Nov 2008 21:11:40 -0700 (MST) bugmail-sender at Sun.COM wrote:
> *Synopsis*: bug in pattern matching

> CR 6766246 changed on Nov 4 2008 by <User 1-5Q-1267>

> === Field ============ === New Value ============= === Old Value =============

> Category               shell                       opensolaris                
> Public Comments        New Note                                               
> SubCategory            korn93                      triage-queue               
> ====================== =========================== ===========================

>      
> *Change Request ID*: 6766246

> *Synopsis*: bug in pattern matching

>   Product: solaris
>   Category: shell
>   Subcategory: korn93
>   Type: Defect
>   Subtype: 
>   Status: 1-Dispatched
>   Substatus: 
>   Priority: 3-Medium
>   Introduced In Release: 
>   Introduced In Build: 
>   Responsible Engineer: 
>   Keywords: opensolaris

> === *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 1): 2008-11-04 04:09:56 GMT+00:00 alan.coopersmith at sun.com

> === *Workaround* =============================================================

> === *Additional Details* =====================================================
>         Targeted Release: 
>         Commit To Fix In Build: 
>         Fixed In Build: 
>         Integrated In Build: 
>         Verified In Build: 
>   See Also: 
>   Duplicate of: 
>   Hooks:
>         Hook1: 
>         Hook2: 
>         Hook3: 
>         Hook4: 
>         Hook5: 
>         Hook6: <email address omitted>
>   Program Management: 
>   Root Cause: 
>   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

> === *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 ======================================

> _______________________________________________
> ksh93-integration-discuss mailing list
> ksh93-integration-discuss at opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/ksh93-integration-discuss


Reply via email to