summaryrefslogtreecommitdiffhomepage
path: root/tests/posix/for-params.sh
blob: 533f0783fe3c3cb97e2baf403964463faa3028fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# A `for` loop without `in` iterates over a copy of "$@", so a `set --` or
# `shift` in the body must not disturb the words still to come.
set -- one two three
for a; do
	set -- xxxxxxxxxxxxxxxx y
	echo "[$a]"
done

set -- one two three
for a; do
	shift
	echo "shift [$a]"
done

f() {
	set -- replaced more
	echo "in f: [$1]"
}
set -- p q
for a; do
	f
	echo "fn [$a]"
done