~ecs/tm

tm/tm -rwxr-xr-x 561 bytes
0022137dEmber Sawady Fix shellcheck warnings 2 years 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
#!/bin/sh -eu

cd "$(dirname -- "$0")"
export PATH="$PWD:$PATH"
cd - >/dev/null
usage() {
	echo "usage: tm <command> [<subcommand>...]"
	echo "valid values for <command>:"
	IFS=:
	for path in $PATH; do
		cd "$path" 2>/dev/null || continue
		IFS=
		for file in tm-*; do
			[ -x "$file" ] && printf "\t%s\n" "${file#tm-}"
		done
		IFS=:
		cd - >/dev/null
	done | sort | uniq
	exit 1
}
[ $# -eq 0 ] && usage
cmd="$1"
shift
if ! which tm-"$cmd" >/dev/null 2>/dev/null; then
	printf "error: invalid command %s\n%s\n" "$cmd" "$(usage)"
	exit 1
fi
exec tm-"$cmd" "$@"