help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] confusion of shell's new option compat41


From: Chet Ramey
Subject: Re: [Help-bash] confusion of shell's new option compat41
Date: Wed, 16 Jan 2013 14:42:04 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

On 1/16/13 1:06 PM, Ma Shimiao wrote:
> According to changelog and manpage, I find compat as a new option is added.
> I have read manpage for many times. But I actually can't find out what it
> affects.
> And I don't understand what special character means.
> 
> ManPage as follow:
> compat41
>             If set, bash, when in posix mode, treats a single quote in a dou‐
>             ble-quoted  parameter expansion as a special character.  The sin‐
>             gle quotes must match (an even number) and the characters between
>             the single quotes are considered quoted.  This is the behavior of
>             posix mode  through  version  4.1.   The  default  bash  behavior
>             remains as in previous versions.
> 
> Could someone give me a example shows how to use compat41?

Look at what a bash-4.2 instance running in Posix mode does with this:

echo "${HOME+'foo}"

with and without compat41 enabled.

The compat41 option changes how this construct is expanded.  With it
enabled, the single quote is special: it is a quote character, must have
an open and close quote, and results in the characters between the single
quotes being sort-of quoted.

I changed bash-4.2 posix mode to conform to a post-bash-4.1 Posix
interpretation.  That interpretation put the burden of matching quotes on
the application, changed single quotes to be ordinary characters in a
double-quoted word expansion, and removed the requirement that the shell
ensure they match.

The default bash behavior doesn't change: it requires that the single
quotes match.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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