Drew Tomlinson <d...@mykitchentable.net> writes:

> It finally occurred to me that I needed the shell to see a new line as
> the delimiter and not whitespace. Then a simple search revealed my
> answer:
>
> O=$IFS
> IFS=$(echo -en "\n\b")
> <do stuff>
> IFS=$O

Old IFS value can be preserved by using `local' keyword or (...) braces, too.
It's a bit better than polluting global scope with temporary variable.

  $ echo -n "$IFS" | (vis -w; echo)
  \040\^I\^J

  $ for i in $(find . -type f); do echo $i; done
  ./My
  Long
  File
  Name
  ./Another
  File

  $ f() { local IFS=; eval "$@"; }
  $ f 'for i in $(find . -type f); do echo $i; done'
  ./My Long File Name
  ./Another File

  $ (IFS=; for i in $(find . -type f); do echo $i; done)
  ./My Long File Name
  ./Another File

  $ echo -n "$IFS" | (vis -w; echo)
  \040\^I\^J
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to