zsh-users
 help / color / mirror / code / Atom feed
* RE: IFS, set, and positional parameters not doing what I expect
@ 2004-03-29  1:29 jason
  0 siblings, 0 replies; 3+ messages in thread
From: jason @ 2004-03-29  1:29 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

> -------- Original Message --------
> Subject: Re: IFS, set, and positional parameters not doing what I
> 
> Works For Me (tm):
> 
> schaefer<501> setopt shwordsplit 
> schaefer<502> f="a:b:c"
> schaefer<503> OFS=$IFS; IFS=: ; set -- $f ; IFS=$OFS
> schaefer<504> echo $1
> a

I must be on drugs.  I swear I tried that 3 different ways and
it didn't work.

Naturally, it works fine now.  Thanks!

--
Jason


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: IFS, set, and positional parameters not doing what I expect
  2004-03-28 22:04 jason
@ 2004-03-29  0:53 ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2004-03-29  0:53 UTC (permalink / raw)
  To: zsh-users

On Mar 28,  3:04pm, jason@jnj.org wrote:
}
} f="a:b:c"
} OFS=$IFS; IFS=: ; set -- $f ; IFS=$OFS
} 
} which sets $1=a, $2=b, $3=c.

This requires either

	set -- ${=f}

Or that you have `setopt sh_word_split'.

} In zsh, this sets $1=a:b:c.  I've tried mucking around with
} the word splitting options to no avail.

Works For Me (tm):

schaefer<501> setopt shwordsplit 
schaefer<502> f="a:b:c"
schaefer<503> OFS=$IFS; IFS=: ; set -- $f ; IFS=$OFS
schaefer<504> echo $1
a
schaefer<505> echo $2
b
schaefer<506> echo $3
c


^ permalink raw reply	[flat|nested] 3+ messages in thread

* IFS, set, and positional parameters not doing what I expect
@ 2004-03-28 22:04 jason
  2004-03-29  0:53 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: jason @ 2004-03-28 22:04 UTC (permalink / raw)
  To: zsh-users

Howdy

In bash and ksh, I do this a lot:

f="a:b:c"
OFS=$IFS; IFS=: ; set -- $f ; IFS=$OFS

which sets $1=a, $2=b, $3=c.

In zsh, this sets $1=a:b:c.  I've tried mucking around with
the word splitting options to no avail.

What am I missing?

--
Jason


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-03-29  1:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-29  1:29 IFS, set, and positional parameters not doing what I expect jason
  -- strict thread matches above, loose matches on Subject: below --
2004-03-28 22:04 jason
2004-03-29  0:53 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).