Skip to main content
added 9 characters in body
Source Link
cuonglm
  • 158.1k
  • 41
  • 341
  • 419

In most POSIX shellscompliant 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 shellscompliant shell, so I wonder is it portable since when POSIX documentation does not specify it?

In most POSIX shells 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 shells, so I wonder is it portable since when POSIX documentation does not specify it?

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?

Source Link
cuonglm
  • 158.1k
  • 41
  • 341
  • 419

Is field splitting and filename expansion turn off in RHS of variable assignment portable?

In most POSIX shells 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 shells, so I wonder is it portable since when POSIX documentation does not specify it?