~nabijaczleweli/voreutils

ref: cb91cf21c628ab3d5e42d89694d99fcca6c8efc8 voreutils/tests/unlink -rwxr-xr-x 761 bytes
cb91cf21наб Add uname (and arch). Centralise spaced print 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# SPDX-License-Identifier: 0BSD

tmpdir="$(mktemp -dt "unlink.XXXXXXXXXX")/"
unlink="${CMDDIR}unlink"

altname="${tmpdir%/}"
altname="${altname##*/}"

cd "$tmpdir" || exit 1

for f in 'file' './file' '--'; do
	for fp in "$f" "${tmpdir}$f"; do
		for pref in '' '--'; do
			"$unlink" $pref "$fp" 2>err && echo "unlink: didn't fail on $fp ($pref)" >&3
			[ -s "err" ] || echo "unlink: no error for $fp ($pref)" >&3

			mkdir -- "$fp"
			"$unlink" $pref "$fp" 2>err && echo "unlink: didn't fail on dir $fp ($pref)" >&3
			[ -s "err" ] || echo "unlink: no error for dir $fp ($pref)" >&3
			rmdir -- "$fp"

			echo > "$fp"
			"$unlink" $pref "$fp"
			[ -f "$fp" ] && echo "unlink: didn't remove $fp ($pref)" >&3
		done
	done
done

cd /
rm -rf "$tmpdir" >&3