Bug 13980

Summary: Parameter expansion pattern removal bug in sh
Product: Base System Reporter: Robert Webb <webbhead>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 2.2.8-STABLE   
Hardware: Any   
OS: Any   

Description Robert Webb 1999-09-26 19:10:01 UTC
The expansion of a Bourne shell parameter with a pattern to be removed
produces garbage characters in place of the removed pattern when the
pattern includes a slash, and the whole expansion string is quoted.

Fix: 

unknown
How-To-Repeat: Run this script:

    #!/bin/sh
    f=/tmp/user/wpage.html
    echo '$f='$f
    echo '${f%.*}='${f%.*}
    echo '${f%/*}='${f%/*}
    echo '${f%"/wpage.html"}='${f%"/wpage.html"}
    echo ''
    echo '"$f"='"$f"
    echo '"${f%.*}"='"${f%.*}"
    echo '"${f%/*}"='"${f%/*}"
    echo '"${f%"/wpage.html"}"='"${f%"/wpage.html"}"

The last two echos output garbage in place of the trailing pattern
which was removed.
Comment 1 Sheldon Hearn 1999-09-27 08:36:16 UTC
On Sun, 26 Sep 1999 07:26:48 MST, Robert Webb wrote:

> The last two echos output garbage in place of the trailing pattern
> which was removed.

The /bin/sh in both 3.2-STABLE and 4.0-CURRENT produce the expected
results:

$f=/tmp/user/wpage.html
${f%.*}=/tmp/user/wpage
${f%/*}=/tmp/user
${f%"/wpage.html"}=/tmp/user

"$f"=/tmp/user/wpage.html
"${f%.*}"=/tmp/user/wpage
"${f%/*}"=/tmp/user
"${f%"/wpage.html"}"=/tmp/user

Time to upgrade? :-)

Ciao,
Sheldon.
Comment 2 robert 1999-09-27 09:06:55 UTC
Sheldon Hearn, at 09:36 AM 9/27/99 +0200, you wrote:
>
>On Sun, 26 Sep 1999 07:26:48 MST, Robert Webb wrote:
>> The last two echos output garbage in place of the trailing pattern
>> which was removed.
>
>The /bin/sh in both 3.2-STABLE and 4.0-CURRENT produce the expected
>results:

That is good news.

>Time to upgrade? :-)

Yes! :)  I already have 3.2 CDs to install at home.  I submitted the
bug report from an account at my ISP, though, and they will have a
difficult time upgrading from 2.2.8 without breaking many customers'
CGIs.  Thanks for checking out this problem, Sheldon.
-- 
Robert  <robert@webbhead.com>
Comment 3 Kris Kennaway freebsd_committer freebsd_triage 2001-05-24 20:17:17 UTC
State Changed
From-To: open->closed

Problem seems to be resolved some time ago