Re: Quoting: is "${foo-'a"b'"}" valid?

2016-09-17 Thread Chet Ramey
On 9/17/16 7:38 AM, Joerg Schilling wrote:
> Chet Ramey  wrote:
> 
>>> But please explain (character by character) why you create an output that 
>>> is in 
>>> conflict with the reference implementation (a patched ksh88).
>>
>> `Character by character'? Really?
>>
>> (And obviously the so-called `reference implementation' doesn't reflect
>> the intent of the standard either, as revealed by the discussion.)
> 
> This claim does not match the general POSIX rules.

So it doesn't really matter what the standard says or what its intent is
determined to be? It only matters what the so-called `reference
implementation' does?

> 
>> Anyway, bash, in its default mode, treats embedded single- and double-
>> quoted strings as special, and skips over them according to the "skipping
>> over enclosed quoted strings" portion of the text in 2.6.2 that's been
>> there since at least 1992.
> 
> /usr/xpg4/bin/sh
> $ echo "${foo-'a"b'"}"
>>
> 
> This is a certified POSIX shell

OK.  If this specific behavior is part of the certification test, then
either the test needs to be changed or the standard does.  If it's not,
then it really doesn't matter what a `certified' shell does.

I'm done with this discussion unless we want to reopen interpretation 221.
There's no path forward from here that's not a huge waste of time
otherwise.

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



Re: Quoting: is "${foo-'a"b'"}" valid?

2016-09-17 Thread Joerg Schilling
Chet Ramey  wrote:

> > But please explain (character by character) why you create an output that 
> > is in 
> > conflict with the reference implementation (a patched ksh88).
>
> `Character by character'? Really?
>
> (And obviously the so-called `reference implementation' doesn't reflect
> the intent of the standard either, as revealed by the discussion.)

This claim does not match the general POSIX rules.

> Anyway, bash, in its default mode, treats embedded single- and double-
> quoted strings as special, and skips over them according to the "skipping
> over enclosed quoted strings" portion of the text in 2.6.2 that's been
> there since at least 1992.

/usr/xpg4/bin/sh
$ echo "${foo-'a"b'"}"
> 

This is a certified POSIX shell

and:

ksh93
joerg@unknown:~/cmd$ echo "${foo-'a"b'"}"
> 

behaves the same

> In 2010-2011, I changed this -- when in Posix mode -- to not treat single
> quotes as special, but to retain the existing treatment of embedded double-
> quoted strings.  This is valid even in the presence of issue 221, which
> leaves the treatment of double quotes inside a double-quoted parameter
> expansion as unspecified.  Bash has never allowed double quotes inside a
> parameter expansion to terminate a double-quoted string that begins
> outside the expansion, so I wasn't going to start then.

If this was the reason for Bourne derived behave diferent from bash, they would 
not print a PS2 prompt.

Jörg

-- 
 EMail:jo...@schily.net(home) Jörg Schilling D-13353 Berlin
   joerg.schill...@fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.org/private/ 
http://sourceforge.net/projects/schilytools/files/'



Re: Quoting: is "${foo-'a"b'"}" valid?

2016-09-17 Thread Joerg Schilling
Vincent Lefevre  wrote:

> > > but the other shells regard them as special:
> > > 
> > > $ foo=abcdef; echo "${foo#'ab'}"
> > > cdef
> > > 
> > > So, is this also unspecified like double quotes? Or should it
> > > be specified that they are special, in which case, dash / ash
> > > are buggy?
> > 
> > Dash conforms to the standard if you execute it as "sh".
>
> No, it doesn't. Try it. :)

Well it behaves the same as the reference implementation /usr/xpg4/bin/sh
which is a "pimped" ksh88.

Jörg

-- 
 EMail:jo...@schily.net(home) Jörg Schilling D-13353 Berlin
   joerg.schill...@fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.org/private/ 
http://sourceforge.net/projects/schilytools/files/'



Re: Quoting: is "${foo-'a"b'"}" valid?

2016-09-10 Thread Chet Ramey
On 9/9/16 7:30 PM, shwares...@aol.com wrote:
> To me the contexts are, for "${foo-'a"b'"}" as a stream of characters:
> begin double quote stream part
>   begin substitution
> parameter-name dash-op begin argument word
>   begin single quote stream part

Stop here.  There is no "single quote stream part" in Posix.  The
expansion occurs within double quotes, so single quotes are not special.

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



Re: Quoting: is "${foo-'a"b'"}" valid?

2016-09-09 Thread Vincent Lefevre
On 2016-09-09 09:02:11 -0400, Chet Ramey wrote:
> On 9/9/16 7:44 AM, Vincent Lefevre wrote:
> > On 2016-09-05 19:12:54 +, Mark Galeck wrote:
> >> The standard says in the section 2.2.3 on Double-Quotes and $ :
> >> "even number of unescaped double-quotes or single-quotes, if any,
> >> shall occur".
> > 
> > Concerning this point, these even number of double-quotes and even
> > number of single-quotes are fulfilled with the example below:
> > 
> >   echo "${foo-'a"b'"}"
> > 
> > But is this valid?
> 
> It's unspecified, so anything goes, as per
> 
> http://austingroupbugs.net/view.php?id=221
> 
> "For parameter expansions other than the four varieties that provide
> for substring processing, within the string of characters from an
> enclosed "${" to the matching '}', the double-quotes within which
> the expansion occurs shall preserve the literal value of all
> characters, with the exception of the characters double-quote,
> backquote, , and . If any unescaped
> double-quote characters occur within the string, other than in
> embedded command substitutions, the behavior is unspecified."

But this will be only in Issue 8.

http://austingroupbugs.net/view.php?id=221 is about "poor
wording", but I don't see where it the above unspecified
in Issue 7.

And one also has:

"For the four varieties of parameter expansion that provide for
substring processing (see [xref to 2.6.2 Parameter Expansion]),
within the string of characters from an enclosed "${" to the
matching '}', the double-quotes within which the expansion occurs
shall have no effect on the handling of any special characters."

There's no unspecified behavior concerning the double quotes.
So, what about the following?

  echo "${foo#'a"b'"}"

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



Re: Quoting: is "${foo-'a"b'"}" valid?

2016-09-09 Thread Chet Ramey
On 9/9/16 7:44 AM, Vincent Lefevre wrote:
> On 2016-09-05 19:12:54 +, Mark Galeck wrote:
>> The standard says in the section 2.2.3 on Double-Quotes and $ :
>> "even number of unescaped double-quotes or single-quotes, if any,
>> shall occur".
> 
> Concerning this point, these even number of double-quotes and even
> number of single-quotes are fulfilled with the example below:
> 
>   echo "${foo-'a"b'"}"
> 
> But is this valid?

It's unspecified, so anything goes, as per

http://austingroupbugs.net/view.php?id=221

"For parameter expansions other than the four varieties that provide
for substring processing, within the string of characters from an
enclosed "${" to the matching '}', the double-quotes within which
the expansion occurs shall preserve the literal value of all
characters, with the exception of the characters double-quote,
backquote, , and . If any unescaped
double-quote characters occur within the string, other than in
embedded command substitutions, the behavior is unspecified."

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



Re: Quoting: is "${foo-'a"b'"}" valid?

2016-09-09 Thread Steffen Nurpmeso
shwares...@aol.com wrote:
 ||> The standard says in the section 2.2.3 on Double-Quotes and $ :
 ||> "even number of unescaped double-quotes or single-quotes, if any,
 ||> shall occur".
 ||
 ||Concerning this point, these even number of double-quotes and even
 ||number of single-quotes are fulfilled with the example below:
 ||
 ||  echo "${foo-'a"b'"}"
 ||
 ||But is this valid?

 |No, it's not valid, that I see... For the purposes of counting the \
 |double quote in a"b loses it's special meaning because a single quote \
 |stream has been 
 |started. The double quote after the closing single quote is matched \

That is an interesting question, and what would have been my
thought, too.

 |by the double quote after the right brace. ksh is waiting for an additional\
 | right 
 |brace and double quote to be typed to complete the command, it seems, \
 |which is proper, and if done should output a"b}. The others appear \

Yes, i would also think the } is double-quote quoted, so this
should have ended up as a"b} and then awaiting more input.
I really wondered how the other interpretations materialize
(except being (bug-)compatible with each other)?

--steffen