Eric Blake | 13 Oct 20:59 2014
Picon

[PATCH] [BUILTIN] cd: support drive letters on Cygwin

The Cygwin platform supports DOS style drive-letter paths such
as "C:\\dir", even though the preferred form is a POSIX-style
"/cygdrive/c/dir".  This can be seen by doing things such as
chdir("c:") (which succeeds) followed by getcwd(NULL, 0) (which
returns the normalized "/cygdrive/c").  However, dash was trying
to perform local manipulations on the argument to 'cd' prior to
calling into libc, in order to update the state of $PWD and
friends; these manipulations were assuming that the user meant
to change to a relative subdirectory of the current location,
as in './c:', instead of honoring the drive letter.  None of
the other dash builtins take a filename and manipulate it to
affect shell state (some, like 'test', take a file name, but as
stat("c:") works just fine, there is no need to normalize).

This patch has no impact outside of cygwin; on cygwin, it takes
advantage of a native function call to canonicalize any
incoming name into preferred form before updating shell state.

Pre-patch:
$ dash -c 'cd c: && echo $PWD'
dash: 1: cd: can't cd to c:

Post-patch:
$ dash -c 'cd c: && echo $PWD'
/cygdrive/c

Signed-off-by: Eric Blake <eblake <at> redhat.com>
---
 ChangeLog |  4 ++++
 src/cd.c  | 14 ++++++++++++++
(Continue reading)

Jose Calvache | 8 Oct 16:53 2014
Picon

Please reply

Dear Sir/Madam, Here is a pdf attachment of my proposal to you. Please
read and reply I would be grateful. Jose Calvache

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

Herbert Xu | 8 Oct 14:11 2014
Picon
Picon

[EXPAND] Optimise nulonly away and just use quoted as before

commit ab657e36b68f4a7e9ddb0f36c455c98d1c069a2c
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Wed Oct 8 20:09:56 2014 +0800

    [EXPAND] Optimise nulonly away and just use quoted as before

    This patch makes a small optimisation by using the same value for
    quoted between evalvar and varvalue by eliminating nulonly and
    passing along quoted instead.

    Signed-off-by: Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index e981a43..5f033df 100644
--- a/ChangeLog
+++ b/ChangeLog
 <at>  <at>  -2,6 +2,7  <at>  <at> 

 	* Split unquoted $ <at> /$* correctly when IFS is set but empty.
 	* Do not split quoted VSLENGTH and VSTRIM.
+	* Optimise nulonly away and just use quoted as before.

 2014-10-07  Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/src/expand.c b/src/expand.c
index dc8ae47..dfb3f0e 100644
--- a/src/expand.c
+++ b/src/expand.c
 <at>  <at>  -722,7 +722,6  <at>  <at>  evalvar(char *p, int flag)
 	ssize_t varlen;
(Continue reading)

Herbert Xu | 8 Oct 09:42 2014
Picon
Picon

[EXPAND] Do not split quoted VSLENGTH and VSTRIM

commit 8ecad23eae02bbdf36fe5dc8e53deb67fb894357
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Wed Oct 8 15:42:08 2014 +0800

    [EXPAND] Do not split quoted VSLENGTH and VSTRIM

    Currently VSLENGTH and VSTRIM* are field-split even within quotes.
    This is obviously wrong.  This patch fixes that.

    Signed-off-by: Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index dd2ee9d..e981a43 100644
--- a/ChangeLog
+++ b/ChangeLog
 <at>  <at>  -1,6 +1,7  <at>  <at> 
 2014-10-08  Herbert Xu <herbert <at> gondor.apana.org.au>

 	* Split unquoted $ <at> /$* correctly when IFS is set but empty.
+	* Do not split quoted VSLENGTH and VSTRIM.

 2014-10-07  Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/src/expand.c b/src/expand.c
index 51ba8a1..dc8ae47 100644
--- a/src/expand.c
+++ b/src/expand.c
 <at>  <at>  -753,28 +753,22  <at>  <at>  vsplus:
 			argstr(p, flag | EXP_TILDE | EXP_WORD);
 			goto end;
(Continue reading)

Herbert Xu | 8 Oct 09:26 2014
Picon
Picon

[EXPAND] Split unquoted $ <at> /$* correctly when IFS is set but empty

commit 3c06acdac0b1ba0e0acdda513a57ee6e31385dce
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Wed Oct 8 15:24:23 2014 +0800

    [EXPAND] Split unquoted $ <at> /$* correctly when IFS is set but empty

    Currently we do not field-split $ <at> /$* when it isn't quoted and IFS
    is set but empty.  This is obviously wrong.  This patch fixes this.

    Signed-off-by: Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index b990628..dd2ee9d 100644
--- a/ChangeLog
+++ b/ChangeLog
 <at>  <at>  -1,3 +1,7  <at>  <at> 
+2014-10-08  Herbert Xu <herbert <at> gondor.apana.org.au>
+
+	* Split unquoted $ <at> /$* correctly when IFS is set but empty.
+
 2014-10-07  Herbert Xu <herbert <at> gondor.apana.org.au>

 	* Use setvareq to set OPTIND initially.
diff --git a/src/expand.c b/src/expand.c
index 11fd7b7..51ba8a1 100644
--- a/src/expand.c
+++ b/src/expand.c
 <at>  <at>  -116,7 +116,7  <at>  <at>  STATIC const char *subevalvar(char *, char *, int, int, int, int, int);
 STATIC char *evalvar(char *, int);
 STATIC size_t strtodest(const char *, const char *, int);
(Continue reading)

Herbert Xu | 8 Oct 04:28 2014
Picon
Picon

Re: Failure of nested substring processing inside double-quotes

On Mon, Oct 06, 2014 at 08:03:13PM +0000, Paul Smith wrote:
> Hi all.  I recently found a bug in dash's handling of substring
> processing, when the variable is contained within quotes.
> 
> In bash, this works:
> 
>   bash$ echo $PWD
>   /home/psmith
> 
>   bash$ echo ${PWD%${PWD##*/}}.
>   /home/.
> 
>   bash$ echo "${PWD%${PWD##*/}}."
>   /home/.
> 
> which is what I expect.  However, in dash we get:
> 
>   dash$ echo $PWD
>   /home/psmith
> 
>   dash$ echo ${PWD%${PWD##*/}}.
>   /home/.
> 
>   dash$ echo "${PWD%${PWD##*/}}."
>   .
> 
> Whoops!  Inside double-quotes dash is mishandling the nested string
> substitution.  If I break it up into two steps it works OK, regardless
> of whether or not it's quoted.
> 
(Continue reading)

Herbert Xu | 6 Oct 04:40 2014
Picon
Picon

[BUILTIN] Exit without arguments in a trap should use status outside traps

Please review:

commit da30b4b787695fbf77e5d941ff350a66ca572bcb
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Mon Oct 6 10:39:47 2014 +0800

    [BUILTIN] Exit without arguments in a trap should use status outside traps

    POSIX now requires that exit without arguments in a trap should
    return the last command status prior to executing traps.  This
    patch implements this behaviour.

    Signed-off-by: Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index 4dc8fa3..d0ec202 100644
--- a/ChangeLog
+++ b/ChangeLog
 <at>  <at>  -1,3 +1,7  <at>  <at> 
+2014-10-06  Herbert Xu <herbert <at> gondor.apana.org.au>
+
+	* Exit without arguments in a trap should use status outside traps.
+
 2014-10-03  Herbert Xu <herbert <at> gondor.apana.org.au>

 	* Do not clobber exitstatus in evalcommand.
diff --git a/src/eval.c b/src/eval.c
index 3f4d957..51a900d 100644
--- a/src/eval.c
+++ b/src/eval.c
(Continue reading)

Herbert Xu | 3 Oct 08:35 2014
Picon
Picon

[EVAL] Do not clobber exitstatus in evalcommand

commit 0d1fb088a4a16569260de4266d4bd359491c6bcd
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Fri Oct 3 14:07:07 2014 +0800

    [EVAL] Do not clobber exitstatus in evalcommand

    All originators of EXERROR have been setting the exitstatus for
    a while now.  So it is no longer appropriate to set it explicitly
    in evalcommand.

    In fact doing so may cause the original exitstatus to be lost.

    Signed-off-by: Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index 9a601df..4dc8fa3 100644
--- a/ChangeLog
+++ b/ChangeLog
 <at>  <at>  -1,3 +1,7  <at>  <at> 
+2014-10-03  Herbert Xu <herbert <at> gondor.apana.org.au>
+
+	* Do not clobber exitstatus in evalcommand.
+
 2014-10-02  Herbert Xu <herbert <at> gondor.apana.org.au>

 	* Fix use-after-free in dotrap/evalstring.
diff --git a/src/eval.c b/src/eval.c
index 0708bf5..3f4d957 100644
--- a/src/eval.c
+++ b/src/eval.c
(Continue reading)

Herbert Xu | 2 Oct 15:10 2014
Picon
Picon

[ERROR] Set exitstatus in onint

commit b4ce4120f87d89476b2d6ab31df43900d2f5ce89
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Thu Oct 2 21:07:55 2014 +0800

    [ERROR] Set exitstatus in onint

    Currently the exit status when we receive SIGINT is set in evalcommand
    which means that it doesn't always get set.  For example, if you press
    CTRL-C at the prompt of an interactive dash, the exit status is not
    set to 130 as it is in many other Bourne shells.

    This patch fixes this by moving the setting of the exit status into
    onint which also simplifies evalcommand.

    Signed-off-by: Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index 81aba60..9a601df 100644
--- a/ChangeLog
+++ b/ChangeLog
 <at>  <at>  -2,6 +2,7  <at>  <at> 

 	* Fix use-after-free in dotrap/evalstring.
 	* Make sure evalskip is zero before running traps.
+	* Set exitstatus in onint.

 2014-09-29  Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/src/error.c b/src/error.c
index 9d31989..f9ea919 100644
(Continue reading)

Herbert Xu | 2 Oct 13:54 2014
Picon
Picon

[TRAP] Make sure evalskip is zero before running traps

While reviewing the trap code I found the following anomaly:

dash -c 'trap ":; echo trap" USR1; while continue; do continue; done'&
while :; do
	kill -USR1 $!
done

One would expect to see a stream of traps but in fact nothing
is printed.  This is because evalskip is non-zero when entering
dotrap so only the first command in the first trap is executed.
tested seem to be fine.

Interestingly this bug also seems to affect bash.  The real ksh
also doesn't print trap, but it seems to not execute the trap at
all as even if you remove the first colon it still prints nothing.

commit d28c13e7119a605ef152a4310e9415dc7ae9b8f3
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Thu Oct 2 19:49:48 2014 +0800

    [TRAP] Make sure evalskip is zero before running traps

    As it is if dotrap is called with evalskip set to a nonzero value,
    it'll try to execute any set traps.  The result is that the first
    command in the first set trap will be executed while the rest of
    the trap will be silently ignored due to evalskip.  This is highly
    counterintuitive, even though both bash and ksh exhibit a similar
    behaviour.

    This patch fixes it by skipping trap processing if evalskip is set
(Continue reading)

Herbert Xu | 2 Oct 02:27 2014
Picon
Picon

[EVAL] Fix use-after-free in dotrap/evalstring

While going through trap code it occured to me that we have a
use-after-free bug.

commit 6c3f73bc536082fec38bd36e6c8a121033c68835
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Thu Oct 2 08:26:06 2014 +0800

    [EVAL] Fix use-after-free in dotrap/evalstring

    The function dotrap calls evalstring using the stored trap string.
    If evalstring then unsets that exact trap string then we will end
    up using freed memory.

    This patch fixes it by making evalstring always duplicate the string
    before using it.

    Signed-off-by: Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index f161a13..a56fc5e 100644
--- a/ChangeLog
+++ b/ChangeLog
 <at>  <at>  -1,3 +1,7  <at>  <at> 
+2014-10-02  Herbert Xu <herbert <at> gondor.apana.org.au>
+
+	* Fix use-after-free in dotrap/evalstring.
+
 2014-09-29  Herbert Xu <herbert <at> gondor.apana.org.au>

 	* Kill pgetc_macro.
(Continue reading)


Gmane