1#! /bin/sh
2#
3# @(#)set.sh	1.5 18/03/11 Copyright 2016-2018 J. Schilling
4#
5
6# Read test core functions
7. ../../common/test-common
8
9#
10# Basic tests to check whether set works as expected.
11#
12docommand se00 "$SHELL -c 's=\"\$(set +o)\"; set -f; eval \"\$s\"; test \"\$s\" = \"\$(set +o)\" && echo OK'" 0 "OK\n" ""
13docommand se01 "$SHELL -c 'echo \$#'" 0 "0\n" ""
14docommand se02 "$SHELL -c 'set -- 1 2 3; echo \$#'" 0 "3\n" ""
15docommand se03 "$SHELL -c 'set -- 1 2 3; set --; echo \$#'" 0 "0\n" ""
16
17#
18# "set -c cmd" must fail
19#
20docommand -noremove se04 "$SHELL -c 'LC_ALL=C; set -c cmd'" "!=0" "" IGNORE
21err=`grep 'option' got.stderr`
22if [ -z "$err" ]; then
23	fail "Test $cmd_label failed: wrong error message"
24fi
25do_remove
26
27docommand se05 "$SHELL -c 'echo bla'" 0 "bla\n" ""
28docommand se06 "$SHELL -c -- 'echo bla'" 0 "bla\n" ""
29
30#
31# set with illegal long option and args must not set the arg vector
32#
33docommand se10 "$SHELL -c -- 'set 1 2 3;command set -o nonexistent a b 2>/dev/null; echo \$@'" 0 "1 2 3\n" ""
34
35success
36