Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Nov 2007 19:18:20 GMT
From:      Richard Seay <rick.seay@yahoo.ca>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/117748: /bin/sh: Backslash quote fails in pattern for substring processing.
Message-ID:  <200711011918.lA1JIKHL019308@www.freebsd.org>
Resent-Message-ID: <200711011920.lA1JK15Y033031@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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@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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711011918.lA1JIKHL019308>