bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unexpected behavior of ${x#word} and ${x/pat/str} in the case comman


From: Chet Ramey
Subject: Re: Unexpected behavior of ${x#word} and ${x/pat/str} in the case command
Date: Thu, 26 Jun 2025 11:30:46 -0400
User-agent: Mozilla Thunderbird

On 6/23/25 5:02 AM, Takaaki Konno wrote:

Bash Version: 5.1
Patch Level: 4
Release Status: release

Description:

Parameters expanded to null by pattern removal or pattern substitution in the
patterns of case clauses produced unexpected results in some cases.

The version of bash in my system is 5.1, but the same results are produced in
bash 5.2.37 I built from source.

Repeat-By:

In the following example, I expected no output, but in fact it output "not
matched".

     x=abc
     case def in
         "${x#abc}"def) ;;
         "${x##abc}"def) ;;
         "${x%abc}"def) ;;
         "${x%%abc}"def) ;;
         "${x/abc/}"def) ;;
         "${x//abc/}"def) ;;
         "${x/#abc/}"def) ;;
         "${x/%abc/}"def) ;;
         *) echo 'not matched'
     esac
     # => not matched

Thanks for the report. I'll fix this after bash-5.3 is released.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]