• Bug#266082: dash: interprets /usr/X11R6/bin/mkdirhier different from ba

    From Gerrit Pape@1:229/2 to Roland Stigge on Wed Aug 18 11:00:13 2004
    From: [email protected]

    forwarded 266082 upstream
    thanks.

    On Mon, Aug 16, 2004 at 06:52:52PM +0200, Roland Stigge wrote:
    The problem seems to be that when creating absolute directory hierarchies with
    "..", the result is not what we want, e.g:

    =========================================
    ernie@atari:/tmp$ mkdir a
    ernie@atari:/tmp$ mkdirhier /tmp/a/../b/c
    ernie@atari:/tmp$ ls b/
    b
    ernie@atari:/tmp$ ls b/b/
    c
    ernie@atari:/tmp$ ls b/b/c/
    =========================================

    This works with bash (/tmp/b/c), and I don't know why not with dash.

    It would be nice if this could be solved in dash, or reassigned to xutils
    if it's bashism in mkdirhier.

    The problem seems to be in dash, I'm forwarding upstream.

    Here's a smaller test case; dash doesn't iterate through all positional parameters if the first one is empty, and that's causing the unexpected behavior:

    $ dash -c 'c=0; set "" 1 2; echo $#; for i; do c=$(($c+1)); done; echo $c'
    3
    2
    $ bash -c 'c=0; set "" 1 2; echo $#; for i; do c=$(($c+1)); done; echo $c'
    3
    3
    $

    It works as expected if the first parameter is not empty, but another
    one:

    $ dash -c 'c=0; set 0 "" 2; echo $#; for i; do c=$(($c+1)); done; echo $c'
    3
    3
    $

    Regards, Gerrit.
    --
    Open projects at http://smarden.org/pape/.


    --
    To UNSUBSCRIBE, email to [email protected]
    with a subject of "unsubscribe". Trouble? Contact [email protected]

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Herbert Xu@1:229/2 to Gerrit Pape on Wed Aug 18 13:50:10 2004
    From: [email protected]

    On Wed, Aug 18, 2004 at 08:35:46AM +0000, Gerrit Pape wrote:

    Here's a smaller test case; dash doesn't iterate through all positional parameters if the first one is empty, and that's causing the unexpected behavior:

    $ dash -c 'c=0; set "" 1 2; echo $#; for i; do c=$(($c+1)); done; echo $c'
    3
    2
    $ bash -c 'c=0; set "" 1 2; echo $#; for i; do c=$(($c+1)); done; echo $c'
    3
    3
    $

    Thanks for the report. This patch should fix it.
    --
    Visit Openswan at http://www.openswan.org/
    Email: Herbert Xu ~{PmV>HI~} <[email protected]>
    Home Page: http://gondor.apana.org.au/~herbert/
    PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

    ===== src/expand.c 1.80 vs edited =====
    --- 1.80/src/expand.c 2004-05-28 22:09:28 +10:00
    +++ edited/src/expand.c 2004-08-18 21:13:40 +10:00
    @@ -976,9 +976,12 @@
    size_t partlen;

    partlen = strlen(p);
    -
    len += partlen;
    - if (len > partlen && sep) {
    +
    + if (!(subtype == VSPLUS || subtype == VSLENGTH))
    + memtodest(p, partlen, syntax, quotes);
    +
    + if (*ap && sep) {
    char *q;

    len++;
    @@ -991,9 +994,6 @@
    STPUTC(sep, q);
    expdest = q;
    }
    -
    - if (!(subtype == VSPLUS || subtype == VSLENGTH))
    - memtodest(p, partlen, syntax, quotes);
    }
    return len;
    case '0':

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Roland Stigge@1:229/2 to Herbert Xu on Wed Aug 18 15:10:07 2004
    From: [email protected]

    On Wed, 2004-08-18 at 13:22, Herbert Xu wrote:
    $ dash -c 'c=0; set "" 1 2; echo $#; for i; do c=$(($c+1)); done; echo $c' 3
    2
    $ bash -c 'c=0; set "" 1 2; echo $#; for i; do c=$(($c+1)); done; echo $c' 3
    3
    $

    Thanks for the report. This patch should fix it.

    It does! Thanks! :-)



    --
    To UNSUBSCRIBE, email to [email protected]
    with a subject of "unsubscribe". Trouble? Contact [email protected]

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)