Skip to Content.
Sympa Menu

sm-sorcery - Re: [SM-Sorcery]handling of $IFS

sm-sorcery AT lists.ibiblio.org

Subject: Discussion of Sorcery related topics

List archive

Chronological Thread  
  • From: Sergey A Lipnevich <sergeyli AT pisem.net>
  • To: Jens Laas <jens.laas AT data.slu.se>
  • Cc: Nick Jennings <nkj AT namodn.com>, sm-sorcery AT lists.ibiblio.org
  • Subject: Re: [SM-Sorcery]handling of $IFS
  • Date: Fri, 18 Oct 2002 12:20:48 -0400

Wow, that's what I was hoping to hear. Great recipe, thanks!

Jens Laas wrote:

(02.10.17 kl.22:10) Nick Jennings skrev följande till
sm-sorcery AT lists.ibib...:


On Fri, Oct 18, 2002 at 12:31:03AM -0400, Sergey A. Lipnevich wrote:

E.g., consider this pice (takes place in libdepends):

save_ifs=$IFS
$IFS=$enter_ifs
for i in file-with-lines-with-spaces; do
$IFS=$save_ifs
do stuff
done
$IFS=$save_ifs

Isn't it a bad hack?
One thing is clear from your answer: there's no way to reset $IFS to
whatever we need and keep it this way. So I'd say we try and find the
way to never touch $IFS at all, if at all possible.


I agree, but I think the alternatives are even more gritty...
At least, the alternatives we've explored.


My experience with IFS has taught me one thing: dont touch it :-)

1.
function func-that-does-stuff {
while read LINE; do
do stuff
done
}
cat file | func-that-does-stuff

2.
cat file |
( while read LINE;
do
echo "Line: $LINE"
done )


Cheers,
Jens Låås

-----------------------------------------------------------------------
'This mail automatically becomes portable when carried.'
-----------------------------------------------------------------------
Jens Låås Email: jens.laas AT data.slu.se
Department of Computer Services, SLU Phone: +46 18 67 35 15
Vindbrovägen 1
P.O. Box 7079
S-750 07 Uppsala
SWEDEN
-----------------------------------------------------------------------

_______________________________________________
SM-Sorcery mailing list
SM-Sorcery AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/sm-sorcery




------------------
Get free mailbox 20 Mb at http://www.hotbox.ru



Archive powered by MHonArc 2.6.24.

Top of Page