svn commit: r341803 - head/libexec/rc

Conrad Meyer cem at freebsd.org
Wed Dec 12 01:00:34 UTC 2018


On Tue, Dec 11, 2018 at 2:42 PM Devin Teske <dteske at freebsd.org> wrote:
> In that case, would it be appropriate to say that:
>
>         blah | while read x; do ...; done
>
> Is always more efficiently written as:
>
>         IFS=$'\n'
>         for x in $( blah ); do ...; done

I don't know.  The suggestion came from jilles@, who is much more
familiar with sh(1) than I am.

My understanding is that it's important that 'set -o noglob' is set,
or else 'blah' lines that include globs may be evaluated against the
filesystem.  There is also a caveat if 'blah' is the 'set' command, or
similar, in that IFS' own value itself will be split across multiple
for loop iteration 'x' values ("IFS='", "'").

I would hesitate to say "always" given my limited understanding of the
shell, but it might be true.

Best,
Conrad


More information about the svn-src-all mailing list