ifs.t

来自「一个开放源代码的 AT&T 的 Korn Shell 的复制品, 支持大多数 k」· T 代码 · 共 163 行

T
163
字号
name: IFS-space-1description:	Simple test, default IFSstdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	set -- A B C	showargs 1 $*	showargs 2 "$*"	showargs 3 $@	showargs 4 "$@"expected-stdout:	 <1> <A> <B> <C>	 <2> <A B C>	 <3> <A> <B> <C>	 <4> <A> <B> <C>---name: IFS-colon-1description:	Simple test, IFS=:stdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	IFS=:	set -- A B C	showargs 1 $*	showargs 2 "$*"	showargs 3 $@	showargs 4 "$@"expected-stdout:	 <1> <A> <B> <C>	 <2> <A:B:C>	 <3> <A> <B> <C>	 <4> <A> <B> <C>---name: IFS-null-1description:	Simple test, IFS=""stdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	IFS=""	set -- A B C	showargs 1 $*	showargs 2 "$*"	showargs 3 $@	showargs 4 "$@"expected-stdout:	 <1> <A B C>	 <2> <ABC>	 <3> <A B C>	 <4> <A B C>---name: IFS-space-colon-1description:	Simple test, IFS=<white-space>:stdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	IFS="IFS:"	set --	showargs 1 $*	showargs 2 "$*"	showargs 3 $@	showargs 4 "$@"	showargs 5 : "$@"expected-stdout:	 <1>	 <2> <>	 <3>	 <4>	 <5> <:>---name: IFS-space-colon-2description:	Simple test, IFS=<white-space>:	At&t ksh fails this, POSIX says the test is correct.stdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	IFS="IFS:"	set --	showargs :"$@"expected-stdout:	 <:>---name: IFS-space-colon-3description:	Simple test, IFS=<white-space>:	pdksh fails both of these testsstdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	IFS="IFS:"	x=	set --	showargs "$x$@"	showargs "$@$x"expected-fail: yesexpected-stdout:	 <>	 <>---name: IFS-space-colon-4description:	Simple test, IFS=<white-space>:stdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	IFS="IFS:"	set --	showargs "$@$@"expected-stdout:	---name: IFS-space-colon-5description:	Simple test, IFS=<white-space>:	Don't know what POSIX thinks of this.  at&t ksh does not do this.stdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	IFS="IFS:"	set --	showargs "${@:-}"expected-stdout:	 <>---name: IFS-subst-1description:	Simple test, IFS=<white-space>:stdin:	showargs() { for i; do echo -n " <$i>"; done; echo; }	IFS="$IFS:"	x=":b: :"	echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo	echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo	showargs 3 $x	showargs 4 :b::	x="a:b:"	echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo	showargs 6 $x	x="a::c"	echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo	showargs 8 $x	echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo	showargs 10 ${FOO-`echo -n h:i`th:ere}	showargs 11 "${FOO-`echo -n h:i`th:ere}"expected-stdout:	1: [] [b] [] []	2: [:b::]	 <3> <> <b> <> <>	 <4> <:b::>	5: [a] [b] []	 <6> <a> <b> <>	7: [a] [] [c]	 <8> <a> <> <c>	9: [h] [ith] [ere]	 <10> <h> <ith> <ere>	 <11> <h:ith:ere>---

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?