Shell POSIX – Field Splitting and Filename Expansion in RHS of Variable Assignment

posixshell

In most POSIX compliant shell like bash. ksh, dash, mksh, pdksh, when variable assignment occur, field splitting and filename expansion (and brace expansion if the shell supports) are not performed in RHS of assignment:

$ IFS=/
$ a=1/2
# Field splitting and filename expansion turned off here
$ b=$a
$ IFS=
$ printf '%s\n' $b
1/2

Some shell's documentation (bash, ksh) mentioned about this, but POSIX documentation didn't.

I can see this behavior in most POSIX compliant shell, so I wonder is it portable since when POSIX documentation does not specify it?

Best Answer

Depends on where you look at. From Chapter 2, Section 9.1:

Each variable assignment shall be expanded for tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal prior to assigning the value.

I would assume that this list is exhaustive, and since field splitting is not mentioned, the lack of field splitting is POSIX-specified.