bug-bash
[Top][All Lists]
Advanced

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

$IFS and "address@hidden:offset}"


From: Stephane Chazelas
Subject: $IFS and "address@hidden:offset}"
Date: Thu, 05 Jun 2008 17:39:58 +0100

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
uname output: Linux sc.homeunix.net 2.6.25-rc8 #1 PREEMPT Fri Apr 4 08:56:07 
BST 2008 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.2
Patch Level: 39
Release Status: release

Hiya,

$ bash -c 'printf "%s\n" "${@:2}"' x 1 2 "3 4" 5
2
3 4
5
$ bash -c 'IFS=a; printf "%s\n" "${@:2}"' 0 1 2 "3 4" 5
2 3 4 5

I don't understand why $IFS would have any influence here. The
behavior differs from ksh.

It seems that you need to have " " in IFS or IFS being unset for
it to work as I would expect.

Also, this:

$ bash -c 'printf "%s\n" "${@:1}"' x 1 2 "3 4" 5
1
2
3 4
5
$ bash -c 'a=("$@"); printf "%s\n" "address@hidden:1}"' x 1 2 "3 4" 5
2
3 4
5

I find is quite confusing.

The behavior is the same in ksh, but in ksh ${@:0:1} expands to
$0 which makes it more understandable ($0 has its meaning in
functions as well in ksh which makes it somehow consistent).

In bash, ${@:0:1} and ${@:1:1} expand to the same thing ($1). Is
all that documented (I couldn't find it via a quick scan of the
man page)?

Best regards,
Stephane




reply via email to

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