Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: SH_WORD_SPLIT, $* and null IFS
- X-seq: zsh-users 15441
- From: Paul Mertz <paul.mertz6@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: SH_WORD_SPLIT, $* and null IFS
- Date: Fri, 1 Oct 2010 09:16:49 +0200
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=pcQdJC46OwbXEjfnm3lzXWSG7dKybNWJPSRxRPTeAEI=; b=X9s9o3iXaYAwgv9wQlBTkZxFCc/zxHYRbOAN23PAAsDJmVl+3vxINlFpJp8d4l1BWH y8M5+m1K++TwPNM0lzE00s7XOQZsC59BKWmqN//Wv4r6p6+IHEB19UXPKxe0lJ+VomWO FjR0y3Szh31NQzsyjwjuTE+MB7p0Gy3b4gyBw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=PVYBg9CVPn/oefzWVrMp5P1IcxoWIdxELcRNUKfUp6Pa1q35Ps0Jw5tWHp7Y4cTbx4 PrpvSWhRpfxzsPTF0AAufSeo5EYywvaigfgXHx6PkZER2iwIuFXNqq/+yXTy7OinHvcL 3BxU+5UhICWACwMOhz9SRRSG9eP8Go+HacbNM=
- In-reply-to: <100930092706.ZM10477@xxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <AANLkTikx9YPujdRz+u56CLcHcSkTVgoe4iYVDD1kbj9r@xxxxxxxxxxxxxx> <100930092706.ZM10477@xxxxxxxxxxxxxxxxxxxxxx>
Thank you for your detailed answer Bart,
I'm puzzled by what you mean about "will not care about the IFS". (Skip
> past the examples for me figuring out what you probably mean.)
>
What I meant by "$* don't care about the ifs" is that the IFS is not
expected to be involved in the joining of parameters when using $* not
enclosed by double quotes (it is however obviously used when expanding each
parameters).
Can you post a specific example showing what you're experiencing?
I should have started by that :)
If we take a look to the following code:
------
host# IFS=
host# set - "a b" "c d" e$'\0'f 'gxh'
host# print -l $*
a b
c d
ef
gxh
host# setopt sh_wordsplit
host# print -l $*
a bc defgxh
-----
We can see that a null IFS (a unset IFS will not trigger this) is actually
changing the behavior of $* when sh_wordsplit is set: parameters are all
joined together. But as far I as know, this kind of joining is only expected
to happen when using "$*" not $*. It's counter-intuitive at best.
>
> Rule 10 plus possibly that last part about rule 22 being skipped when
> single words are not required is what causes the behavior on joining.
> When IFS is empty, the words are joined at step 10 but NOT split again
> at 17, and rule 22 doesn't matter. When IFS is non-empty, the words
> are joined at 10, then split at 17, and then NOT joined at 22.
> My recollection (which may be wrong) is that POSIX leaves unspecified
> (or makes implementation-defined) the order in which this occurs, and
> requires that the double quotes be used to get defined behavior.
>
This could indeed explain why for example bash and ksh, which are splitting
words by default, do react in the "right" way, while dash and maybe other
shell have this (highly) unexpected behavior... I just found strange that
it's apparently not documented anywhere... But i guess it's not that
important...
Anyway, thank you for your time,
Paul
Messages sorted by:
Reverse Date,
Date,
Thread,
Author