1

In Bourne shell and derivates,

Is IFS a shell-builtin, an Environment variable, or something else, by definition?
(How is this program module normally categorized in the literature?)

1 Answers1

1

According to this source, 2. Shell Command Language:

2.5.3 Shell Variables

Variables shall be initialized from the environment (as defined by XBD Environment Variables and the exec function in the System Interfaces volume of POSIX.1-2017) and can be given new values with variable assignment commands. If a variable is initialized from the environment, it shall be marked for export immediately; see the export special built-in. New variables can be defined and initialized with variable assignments, with the read or getopts utilities, with the name parameter in a for loop, with the ${ name= word} expansion, or with other mechanisms provided as implementation extensions.

And specifically IFS:

IFS A string treated as a list of characters that is used for field splitting, expansion of the * special parameter, and to split lines into fields with the read utility. If the value of IFS includes any bytes that do not form part of a valid character, the results of field splitting, expansion of *, and use of the read utility are unspecified.

If IFS is not set, it shall behave as normal for an unset variable, except that field splitting by the shell and line splitting by the read utility shall be performed as if the value of IFS is <space> <tab> <newline>; see Field Splitting.

The shell shall set IFS to <space> <tab> <newline> when it is invoked.

ilkkachu
  • 138,973