HOME

TheInfoList



OR:

For many command line interpreters (“shell”) of
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s, the input field separators or internal field separators or
shell variable An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs. For example, a running process can query the value of the TEMP env ...
holds characters used to separate text into tokens. The value of , (in the bash shell) typically includes the
space Space is the boundless three-dimensional extent in which objects and events have relative position and direction. In classical physics, physical space is often conceived in three linear dimensions, although modern physicists usually con ...
, tab, and the
newline Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or a ...
characters by default. These whitespace characters can be visualized by issuing the "declare" command in the bash shell or printing with commands like printf %s "$IFS" , od -c, printf "%q\n" "$IFS" or printf %s "$IFS" , cat -A (the latter two commands being only available in some shells and on some systems). From the
Bash Bash or BASH may refer to: Arts and entertainment * ''Bash!'' (Rockapella album), 1992 * ''Bash!'' (Dave Bailey album), 1961 * '' Bash: Latter-Day Plays'', a dramatic triptych * ''BASH!'' (role-playing game), a 2005 superhero game * "Bash" ('' ...
, version 4
man page A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and ev ...
:
The shell treats each character of as a
delimiter A delimiter is a sequence of one or more characters for specifying the boundary between separate, independent regions in plain text, mathematical expressions or other data streams. An example of a delimiter is the comma character, which acts as ...
, and splits the results of the other expansions into words on these characters. If is unset, or its value is exactly , the default, then sequences of , , and at the beginning and end of the results of the previous expansions are ignored, and any sequence of characters not at the beginning or end serves to delimit words. If has a value other than the default, then sequences of the whitespace characters and are ignored at the beginning and end of the word, as long as the whitespace character is in the value of (an whitespace character). Any character in that is not whitespace, along with any adjacent whitespace characters, delimits a field. A sequence of whitespace characters is also treated as a delimiter. If the value of is null, no word splitting occurs.


IFS abbreviation

According to the Open Group Base Specifications, is an abbreviation for "input field separators." A newer version of this specification mentions that "this name is misleading as the IFS characters are actually used as field terminators." However is often referred to as "internal field separators."


Exploits

IFS was usable as an exploit in some versions of Unix. A program with root permissions could be fooled into executing user-supplied code if it ran (for instance) system("/bin/mail") and was called with set to , in which case it would run the program "" (in the current directory and thus writable by the user) with root permissions. This has been fixed by making the shells not inherit the IFS variable.


References

Unix {{compsci-stub