bin/117748: /bin/sh: Backslash quote fails in pattern for substring processing.

Richard Seay rick.seay at yahoo.ca
Thu Nov 1 12:20:01 PDT 2007


>Number:         117748
>Category:       bin
>Synopsis:       /bin/sh:  Backslash quote fails in pattern for substring processing.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 01 19:20:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Richard Seay
>Release:        6.2-RELEASE-p5
>Organization:
>Environment:
$ uname -a
FreeBSD 78NVNXM 6.2-RELEASE-p5 FreeBSD 6.2-RELEASE-p5 #0: Fri Jun 22 13:02:29 EDT 2007     root at 78NVNXM:/usr/obj/usr/src/sys/KERNEL  i386
>Description:
Trying to match a literal question mark in a string for substring processing, the question mark (?) in the pattern cannot be quoted.

This is what I would expect (using ksh93):

$ echo $SHELL
/usr/local/bin/ksh93
$ export s=foo?bar
$ echo $s
foo?bar
$ echo ${s%\?*}
foo
$ echo ${s#*\?}
bar

This is what happens (using sh):

$ /bin/sh
$ echo $s
foo?bar
$ echo ${s%\?*}
foo?ba
$ echo ${s#*\?}
oo?bar

Bash shows the same behaviour as ksh93.

>How-To-Repeat:
See above.
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list