1#! /shell/bug/test/for/moderni/sh
2# See the file LICENSE in the main modernish directory for the licence.
3#
4# BUG_IFSISSET: Cannot test in any normal way if IFS is set. On ksh93, the only way
5# to test if IFS is set or not is by analysing the shell's field splitting behaviour.
6#
7# Bug found on: AT&T ksh93 versions JM 93u 2011-02-08, AJM 93u+ 2012-08-01
8
9
10# Save IFS: value and set/unset status. Due to the bug we're trying to detect, we can't test
11# if IFS is set by any normal method. The workaround is to analyse field splitting behaviour.
12case ${IFS:+n} in
13( '' )	set -- "a b c"			# empty: test for default field splitting
14	set -- $1
15	case $# in
16	( 1 )	_Msh_t_IFS='' ;;	# no field splitting: it is empty and set
17	( * )	unset -v _Msh_t_IFS ;;	# default field splitting: it is unset
18	esac ;;
19( * )	_Msh_t_IFS=$IFS ;;		# it is set and non-empty
20esac
21
22# Detect the bug.
23unset -v IFS
24case ${IFS+s} in
25( '' )	_Msh_test=n ;;
26( s )	_Msh_test=y ;;
27esac
28
29# Restore IFS.
30case ${_Msh_t_IFS+s} in
31( s )	IFS=${_Msh_t_IFS}; unset -v _Msh_t_IFS ;;
32( * )	unset -v IFS ;;
33esac
34
35# Return result.
36case ${_Msh_test} in
37( n )	return 1 ;;
38esac
39