bug-bash
[Top][All Lists]
Advanced

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

${1:+"$@"} results differnt from "$@" if IFS is NOT default


From: fumiya
Subject: ${1:+"$@"} results differnt from "$@" if IFS is NOT default
Date: 23 Jan 2004 05:40:45 -0000

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -I.  -I../bash -I../bash/include 
-I../bash/lib  -g -O2
uname output: Linux sugar 2.4.24-xfs-fumiya-1 #1 Mon Jan 19 21:55:52 JST 2004 
i686 GNU/Linux
Machine Type: i386-pc-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
        If IFS has NO default value, ${1:+"$@"} results "$1 $2 $3 ...",
        but "$@" results "$1" "$2" "$3" ... .

Repeat-By:
        Test script (t.sh):
        ----------------------------------------
        echo_argc()
        {
            echo $#
        }

        a()
        {
            shift
            echo_argc "$@"
            echo_argc ${1:+"$@"}
            echo_argc "${1:address@hidden"
            echo_argc 1 2 3
        }

        b()
        {
            _IFS="$_IFS"
            IFS="$1"; shift
            echo_argc "$@"
            echo_argc ${1:+"$@"}
            echo_argc "${1:address@hidden"
            echo_argc 1 2 3
            IFS="$_IFS"
        }

        a "X" foo bar hoge
        echo
        b "X" foo bar hoge
        ----------------------------------------

        $ /bin/bash t.sh
        3
        3
        3
        3

        3
        1
        1
        3

        $ /bin/dash t.sh
        (or `/bin/ksh t.sh`)
        (or `/bin/zsh t.sh`)
        3
        3
        3
        3

        3
        3
        3
        3

        But on Solaris 8:
        $ /bin/sh t.sh
        3
        3
        3
        3

        1
        1
        1
        3





reply via email to

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