On Sun, May 12, 2024 at 07:56:55PM +1000, Alexis wrote:
> Andreas Kähäri <andreas.kah...@abc.se> writes:
> 
> > The ksh(1) shell sets IFS by default to a space, tab and a newline
> > character.
> 
> Those are the defaults used when IFS is not set _as a variable_. If you log
> in, and run env(1), in the absence of any manual setting of IFS in .kshrc or
> whatever, you'll see that IFS is not listed, because it's not 'set' in the
> shell variable sense. When it's not set, the shell assumes that IFS has the
> value you listed.
> 
> (Additionally, a shell variable not being set is _not_ the same as that
> variable being set to the empty string.)
> 
> 
> Alexis.

The external env(1) utility will only ever list environment variables.
The IFS variable does not need to be exported as an environment variable
as it's only ever used by the current shell (and any new shell would
reset it).

To list all variables in a shell, use the built-in set utility without
any arguments.

$ (unset -v IFS; ksh -c 'set' | grep -A 1 IFS)
IFS='
'

$ (unset -v IFS; ksh -c 'printf "%s" "$IFS" | hexdump -C')
00000000  20 09 0a                                          | ..|
00000003



-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.

Reply via email to