tech-userlevel@netbsd.org
[Top] [All Lists]

Re: rc.d/network

Subject: Re: rc.d/network
From: Robert Elz
Date: Sat, 20 Sep 2008 03:27:13 +0700
    Date:        Fri, 19 Sep 2008 19:32:33 +0000 (UTC)
    From:        christos@xxxxxxxxxx (Christos Zoulas)
    Message-ID:  <gb0uoh$omi$1@xxxxxxxxxxxxx>

  | Why "eval set -- \$argslist" instead of "set -- $argslist"?

epsilon$ args="a b c;d e f"
epsilon$ IFS=';' set -- $args
epsilon$ echo $#
5
epsilon$ IFS=';' eval set -- \$args
epsilon$ echo $#
2


That is, in the version without eval, $argslist (which I was too
lazy to type in my example) is broken up before IFS gets altered to
adjust the way it is broken up, with  eval, IFS is set first.

This is also possible

epsilon$ IFS=';'; set -- $args
epsilon$ echo $#
2

but then IFS needs to be explicitly set back to its old value afterwards,
with the IFS= prefix to eval (or just set) the shell takes care of that.

kre

<Prev in Thread] Current Thread [Next in Thread>