Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-03-01 Thread Herbert Xu
On Thu, Mar 01, 2018 at 08:24:22PM +0100, Harald van Dijk wrote:
> On 01/03/2018 00:04, Harald van Dijk wrote:
> >$ bash -c 'x=yz; echo "${x#'"'y'"'}"'
> >z
> >
> >$ dash -c 'x=yz; echo "${x#'"'y'"'}"'
> >yz
> >
> >(That is, they are executing x=yz; echo "${x#'y'}".)
> >
> >POSIX says that in "${var#pattern}" (and the same for ##, % and %%), the
> >pattern is considered unquoted regardless of the outer quotation marks.
> >Because of that, the single quote characters should not be taken
> >literally, but should be taken as quoting the y. ksh, posh and zsh agree
> >with bash.
> 
> Unfortunately, this causes another problem with all of the backslash
> approaches so far:
> 
>   x=''; printf "%s\n" "${x#''}"
> 
> This should print a blank line. (bash, ksh, posh and zsh agree.)
> 
> Here, dash's parser stores '$\$\', where $ is a control character. preglob
> would need to turn this into . The problem is again that preglob
> cannot increase the string length. Perhaps the parser needs to store this as
> '$\$\$\$\', $ being either CTLESC or that new CTLBACK? Either way, it
> requires some more invasive changes.

These are different issues.  dash's parser currently does not
understand nested quoting in patterns at all.  That is, if your
parameter expansion are within double quotes, then dash at the
parser level will consider the pattern to be double-quoted.  Thus
any nested single-quotes will be literals instead of actual quotes.

If we fix this in the parser then everything should just work.

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] histedit: fix build with musl libc

2018-03-01 Thread Baruch Siach
musl libc defines the optreset BSD extension only in getopt.h. This
fixes the following build failure:

histedit.c: In function 'histcmd':
histedit.c:220:2: error: 'optreset' undeclared (first use in this function)
  optreset = 1; optind = 1; /* initialize getopt */
  ^~~~

Signed-off-by: Baruch Siach 
---
 src/histedit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/histedit.c b/src/histedit.c
index 94465d785cc9..f5c90aba873b 100644
--- a/src/histedit.c
+++ b/src/histedit.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 /*
  * Editline and history functions (and glue).
  */
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-03-01 Thread Harald van Dijk

On 01/03/2018 00:04, Harald van Dijk wrote:

$ bash -c 'x=yz; echo "${x#'"'y'"'}"'
z

$ dash -c 'x=yz; echo "${x#'"'y'"'}"'
yz

(That is, they are executing x=yz; echo "${x#'y'}".)

POSIX says that in "${var#pattern}" (and the same for ##, % and %%), the 
pattern is considered unquoted regardless of the outer quotation marks. 
Because of that, the single quote characters should not be taken 
literally, but should be taken as quoting the y. ksh, posh and zsh agree 
with bash.


Unfortunately, this causes another problem with all of the backslash 
approaches so far:


  x=''; printf "%s\n" "${x#''}"

This should print a blank line. (bash, ksh, posh and zsh agree.)

Here, dash's parser stores '$\$\', where $ is a control character. 
preglob would need to turn this into . The problem is again that 
preglob cannot increase the string length. Perhaps the parser needs to 
store this as '$\$\$\$\', $ being either CTLESC or that new CTLBACK? 
Either way, it requires some more invasive changes.


Cheers,
Harald van Dijk
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Request

2018-03-01 Thread Mr. LEUNG Cheung
I have something very important to share with you.

Thanks
Mr. LEUNG Cheung
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html