1# tilde-y.tst: yash-specific test of tilde expansion 2 3setup -d 4 5test_oE -e 0 'tilde expansion with $HOME unset' 6unset HOME 7echoraw ~ 8__IN__ 9~ 10__OUT__ 11 12( 13if id _no_such_user_ >/dev/null 2>&1; then 14 skip="true" 15fi 16# The below test case should be skipped if the user "_no_such_user_" exists and 17# the shell has a permission to show its home directory. However, the above 18# test may fail to skip the test case if the "id" utility still don't have a 19# permission to show its attributes. I assume such a special case doesn't 20# actually happen. 21 22test_oE -e 0 'tilde expansion for unknown user' 23echoraw ~_no_such_user_ 24__IN__ 25~_no_such_user_ 26__OUT__ 27 28) 29 30test_oE '~+' 31PWD=/pwd 32echoraw ~+ 33__IN__ 34/pwd 35__OUT__ 36 37test_oE '~-' 38OLDPWD=/old-pwd 39echoraw ~- 40__IN__ 41/old-pwd 42__OUT__ 43 44( 45if ! testee -c 'command -bv pushd' >/dev/null; then 46 skip="true" 47fi 48 49test_oE -e 0 'tilde expansion for directory stack entry' 50PWD=/pwd 51unset DIRSTACK 52echoraw ~+0 ~-0 53DIRSTACK=(/foo /bar/baz) 54echoraw ~+0 ~+1 ~+2 ~+3 55echoraw ~-0 ~-1 ~-2 ~-3 56__IN__ 57/pwd /pwd 58/pwd /bar/baz /foo ~+3 59/foo /bar/baz /pwd ~-3 60__OUT__ 61 62) 63 64# POSIX says, "The pathname resulting from tilde expansion shall be treated as 65# if quoted to prevent it being altered by field splitting and pathname 66# expansion." (XCU 2.6.1) On the other hand, the results of parameter expansion 67# is generally subject to field splitting and pathname expansion. (XCU 2.6.5) 68# Yash prevents such additional expansion in accordance with other shells. 69test_oE 'result of tilde expansion in expansion not for further expansion' 70HOME='/path/with $space$(:)`:`$((1))' IFS=' /' 71echoraw ${u-~} 72HOME='*' 73echoraw ${u-~} 74__IN__ 75/path/with $space$(:)`:`$((1)) 76* 77__OUT__ 78 79# vim: set ft=sh ts=8 sts=4 sw=4 noet: 80