The following few threads on this site and StackOverflow were helpful for understanding how IFS works: What is IFS in context of for looping? How to loop over the lines of a file Bash, read line by...
Using IFS= LC_ALL=C read -r line works around it there. Using var=value cmd syntax makes sure IFS / LC_ALL are only set differently for the duration of that cmd command. History note The read builtin was introduced by the Bourne shell and was already to read words, not lines. There are a few important differences with modern POSIX shells.
Here if the expansion contains any IFS characters, then it split into different 'words' before the command is processed. Effectively this means that these characters split the substituted text into different arguments (including the name of the command if the variable is specified first).
Here is an example of behavior I want to achieve: Suppose I have a list of lines, each line containing space separated values: lines='John Smith James Johnson' And I want to loop over lines echoin...
How do I correctly run a few commands with an altered value of the IFS variable (to change the way field splitting works and how "$*" is handled), and then restore the original value of I...
The IFS= read -r line sets the environment variable IFS (to an empty value) specifically for the execution of read. This is an instance of the general simple command syntax: a (possibly empty) sequence of variable assignments followed by a command name and its arguments (also, you can throw in redirections at any point).
¹ Though note that it splits ::a:b::c::: into a, b and c only like IFS-splitting did in the Bourne shell (but not in modern Bourne-like shells except when space, tab or newline are used as separators).