1
0
Files
irix-657m-src/eoe/cmd/ksh/tests/quoting.sh
2022-09-29 17:59:04 +03:00

69 lines
1.9 KiB
Bash
Executable File

#
# Copyright (c) 1984,1985,1986,1987,1988,1989,1990 AT&T
# All Rights Reserved
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T.
# The copyright notice above does not evidence any
# actual or intended publication of such source code.
#
function err_exit
{
print -u2 -n "\t"
print -u2 -r $Command: "$@"
let Errors+=1
}
Command=$0
integer Errors=0
if [[ 'hi there' != "hi there" ]]
then err_exit "single quotes not the same as double quotes"
fi
x='hi there'
if [[ $x != 'hi there' ]]
then err_exit "$x not the same as 'hi there'"
fi
if [[ $x != "hi there" ]]
then err_exit "$x not the same as \"hi there \""
fi
if [[ \a\b\c\*\|\"\ \\ != 'abc*|" \' ]]
then err_exit " \\ differs from '' "
fi
if [[ "ab\'\"\$(" != 'ab\'\''"$(' ]]
then err_exit " \"\" differs from '' "
fi
if [[ $(print -r - 'abc*|" \') != 'abc*|" \' ]]
then err_exit "\$(print -r - '') differs from ''"
fi
if [[ $(print -r - "abc*|\" \\") != 'abc*|" \' ]]
then err_exit "\$(print -r - '') differs from ''"
fi
if [[ "$(print -r - 'abc*|" \')" != 'abc*|" \' ]]
then err_exit "\"\$(print -r - '')\" differs from ''"
fi
if [[ "$(print -r - "abc*|\" \\")" != 'abc*|" \' ]]
then err_exit "\"\$(print -r - "")\" differs from ''"
fi
if [[ $(print -r - $(print -r - 'abc*|" \')) != 'abc*|" \' ]]
then err_exit "nested \$(print -r - '') differs from ''"
fi
if [[ "$(print -r - $(print -r - 'abc*|" \'))" != 'abc*|" \' ]]
then err_exit "\"nested \$(print -r - '')\" differs from ''"
fi
if [[ $(print -r - "$(print -r - 'abc*|" \')") != 'abc*|" \' ]]
then err_exit "nested \"\$(print -r - '')\" differs from ''"
fi
unset x
if [[ ${x-$(print -r - "abc*|\" \\")} != 'abc*|" \' ]]
then err_exit "\${x-\$(print -r - '')} differs from ''"
fi
if [[ ${x-$(print -r - "a}c*|\" \\")} != 'a}c*|" \' ]]
then err_exit "\${x-\$(print -r - '}')} differs from ''"
fi
x=$((echo foo)|(cat))
if [[ $x != foo ]]
then err_exit "((cmd)|(cmd)) failed"
fi
exit $((Errors))