aboutsummaryrefslogtreecommitdiffstats
path: root/help
blob: 19d26ec37399ce298837a5f9dfa73fae319f21d7 (plain)
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
32
#!/bin/sh

# usage:	help - Lists all the available commands
#		help <command> - Detailled explanation of how "command" works

if tty -s
then
	HELPTEXT="Hi $USER, Run 'help' for help, 'help <command>' for specific help on a command, run 'exit' to exit. Available commands:"
else
	HELPTEXT="Hi $USER, Run 'help' for help, 'help <command>' for specific help on a command. Available commands:"
fi

cd "$(dirname "$0")"

if [[ ! -z $1 ]]; then
	cmd=$1
	if [[ -f $cmd && -x $cmd ]]; then
		awk 'NR>=3&&NR<=4' $cmd | cut -c 3-
	else
		echo "command \"$cmd\" doesn't exists"
	fi
else
	echo $HELPTEXT
	for cmd in *
	do
		case "$cmd" in
		help) ;;
		*) [ -f "$cmd" ] && [ -x "$cmd" ] && echo "$cmd" ;;
		esac
	done
fi