Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Oct 2001 16:22:56 +0200
From:      "Karsten W. Rohrbach" <karsten@rohrbach.de>
To:        "Daniel C. Sobral" <dcs@newsguy.com>
Cc:        Stijn Hoop <stijn@win.tue.nl>, "Eugene L. Vorokov" <vel@bugz.infotecs.ru>, freebsd-hackers@freebsd.org
Subject:   Re: how to make 'for' understand two words as a single argument
Message-ID:  <20011002162256.E12706@mail.webmonster.de>
In-Reply-To: <3BB9B0A3.2C5F3ACC@newsguy.com>; from dcs@newsguy.com on Tue, Oct 02, 2001 at 09:18:43AM -0300
References:  <200110011039.f91AdOD88292@bugz.infotecs.ru> <3BB855BB.D10C5030@newsguy.com> <20011001135635.A39309@pcwin002.win.tue.nl> <3BB9B0A3.2C5F3ACC@newsguy.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--brEuL7wsLY8+TuWz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Daniel C. Sobral(dcs@newsguy.com)@2001.10.02 09:18:43 +0000:
> Stijn Hoop wrote:
> >=20
> > > Any way using `` won't work. for i in a "b c" d works, for instance, =
but
> > > there is not way that I know of that you can control the output this =
way
> > > using ``.
> >=20
> > Yes there is: set IFS to only contain a newline beforehand. That's my l=
ocal
> > hack, your way is probably better :)
>=20
> But if you do that, you'll get a single argument back, instead of a
> number of arguments, some of which have space in the middle, or not?

you should save IFS somewhere, anyway.
you might do

[...]
OLDIFS=3D"${IFS}"
IFS=3D'
'
for i in "`command`"; do
    IFS=3D"${OLDIFS}"
    echo "${i}" | read one two
    othercommand ${one} more arguments -paramaters ${two}
    IFS=3D'
'
done
[...]

in bournish shells. i am a zsh user, so perhaps this won't work in
/bin/sh...

arguments should be parsed as expanded text, so it should not really
matter if you use them as subsequent arguments. the technique with
echo'ing the value through read splits it into the two variables.

does this make sense?

/k

--=20
> MCSE: Management Can't Send E-mail
KR433/KR11-RIPE -- WebMonster Community Founder -- nGENn GmbH Senior Techie
http://www.webmonster.de/ -- ftp://ftp.webmonster.de/ -- http://www.ngenn.n=
et/
karsten&rohrbach.de -- alpha&ngenn.net -- alpha&scene.org -- catch@spam.de
GnuPG 0x2964BF46 2001-03-15 42F9 9FFF 50D4 2F38 DBEE  DF22 3340 4F4E 2964 B=
F46
Please do not remove my address from To: and Cc: fields in mailing lists. 1=
0x

--brEuL7wsLY8+TuWz
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE7uc3AM0BPTilkv0YRAlX5AJ9Z3cZRaxjOHSDqhe9XSU//dvLsagCaAn+m
krnlb2QSjkF7+tVts4q4i3A=
=Ug5h
-----END PGP SIGNATURE-----

--brEuL7wsLY8+TuWz--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011002162256.E12706>