[comp.unix.wizards] Shell & IFS

brandon@tdi2.UUCP (02/25/87)

Expires:

Quoted from <4560@brl-adm.ARPA> ["Make is Buggy"], by rbj@icst-cmr.arpa (Root Boy Jim)...
+---------------
|    ]>Furthermore, it is a botch to *import* SHELL from the environment;
|    ]>this causes Makefiles to work differently for people with different
|    ]>login shells!  "make" should NOT import SHELL.
+---------------

AMEN!  Plexus ships a buggy csh with System V; I use it.  Mix it with make
and KABOOM!  I'm not happy with make.

+---------------
|    ]And it *certainly* should not attempt to import things like IFS!
| 
| Well, John Mashey once suggested asking `why' before flaming, and since
| someone brought it up, *** why does IFS even exist *** ?
+---------------

It's a kludgy way to do things that can be done in other ways (albeit more
slowly).  Example:

IFS=':
' # newline and colon
while read name pass uid gid comment home shell; do
	# do something with them
done < /etc/passwd

This is the ONLY way I've seen it used; frankly, I use "awk" if I want to
process a file in this way anyway, so I see no real use for IFS.

++Brandon
-- 
``for is he not of the Children of Luthien?  Never shall that line fail, though
the years may lengthen beyond count.''  --J. R. R. Tolkien

Brandon S. Allbery	           UUCP: cbatt!cwruecmp!ncoast!tdi2!brandon
Tridelta Industries, Inc.         CSNET: ncoast!allbery@Case
7350 Corporate Blvd.	       INTERNET: ncoast!allbery%Case.CSNET@relay.CS.NET
Mentor, Ohio 44060		  PHONE: +1 216 255 1080 (home) +1 216 974 9210

jty@intrin.UUCP (03/03/87)

In article <140@tdi2.UUCP> brandon@tdi2.UUCP (Brandon Allbery) writes:
>IFS=':
>' # newline and colon
>while read name pass uid gid comment home shell; do
>	# do something with them
>done < /etc/passwd
>
>This is the ONLY way I've seen it used; frankly, I use "awk" if I want to
>process a file in this way anyway, so I see no real use for IFS.

Nope!

IFS comes in handy if you want to parse command output or, say, PATH
----------
: 'this is a functional equivalent to SV sh type command'
IFS=":$IFS"
for CMD
do
	for DIR in $PATH
	do
		if test -x $DIR/$CMD
		then
			echo $DIR/$CMD 
		fi
	done
done
-----------
IFS=":$IFS"
set `date`
echo It\'s $4.$5
-- 
Jyrki Yli-Nokari, Intrinsic Oy, SF-33100 Tampere, FINLAND

USENET:      INTERNET:    BITNET:          FUNET:        TELEPHONE:
intrin!jty   jty@tut.FI   YLI at FINTUTA   TTKKLK::YLI   +358 31 132800

rbj@icst-cmr.arpa (Root Boy Jim) (03/10/87)

   * We already went through the discussion of what @ is called.

It's a `circlethorp', right? :-)

   Wilson H. Bent, Jr.		... ihnp4!hoh-1!whb
   AT&T - Bell Laboratories	(201) 949-1277
   Disclaimer: My company has not authorized me to issue a disclaimer.

	(Root Boy) Jim "Just Say Yes" Cottrell	<rbj@icst-cmr.arpa>
	Why did Paul Simon name his album after Elvis Presley's house?