Answering questions that may arise related to the meaning of portions of an IEEE standard concerning specific applications.

IEEE Standards Interpretations for IEEE Std 1003.2™-1992 IEEE Standard for Information Technology--Portable Operating System Interfaces (POSIX®)--Part 2: Shell and Utilities

Copyright © 1996 by the Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue New York, New York 10016-5997 USA All Rights Reserved.

Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.

IEEE Standards Department, Copyrights and Permissions, 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA

Interpretation Request #98
Topic: field splitting Relevant Clauses: 3.6.5

A question regarding field splitting has come up. Consider the following script: IFS=: x=: set -- $x echo $# The question is whether there should be a terminal empty field. Historically, ksh has reported the number of fields as 1. Moreover, if the number of fields was considered to be 2, there would be no way to describe a single empty field. However, standard 1003.2-1992 seems unclear on this point. The relevant subclause (3.6.5) is quoted below. (An addition I made for brevity and clarity is marked with asterisks). Would appreciate formal clarification.

"Otherwise **(i.e., IFS is set, non-null, and not equal to space tab, newline)** the following rules shall be applied in sequence. The term "IFS white space" is used to mean any sequence (zero or more instances) of white-space characters that are in the IFS value (e.g., if IFS contains <space><comma><tab>, any sequence of <space> and <tab> characters is considered IFS white space). a. IFS white space shall be ignored at the beginning and end of the input. b. Each occurrence in the input of an IFS character that is not IFS IFS white space, along with any adjacent IFS white space, shall delimit a field, as described previously. c. Nonzero-length IFS white space shall delimit a field."

Interpretation Response
According to the example, the number of fields is 1. The standard consistently uses delimiter as field terminator, not field separator and conforming implementations must conform to this.

Rationale for Interpretation