commit 12d5a0a

hovercats  ·  2024-09-03 17:40:15 +0000 UTC
parent 2660c89
check for number of arguments, as opposed to only checking wether $2 is empty or not
1 files changed,  +18, -18
M rcsm
M rcsm
+18, -18
 1@@ -9,29 +9,29 @@ fn usage {
 2 }
 3 
 4 fn run {
 5-	if (test -z $2) {
 6-		for (serv in $basedir/run/*) {
 7-			$serv $1 >/dev/null >[2=1]  &
 8-		}
 9-	}
10-	if not {
11-		$basedir/avail/$2 $1 >/dev/null >[2=1]  &
12+	switch($#*) {
13+		case 1
14+			for (serv in $basedir/run/*) {
15+				$serv $1 >/dev/null >[2=1]  &
16+			}
17+		case 2
18+			$basedir/avail/$2 $1 >/dev/null >[2=1]  &
19 	}
20 }
21 
22 switch($1) {
23 case -a
24-	if (test -z $2) {
25-		find $basedir/run -type l
26-	}
27-	if not {
28-		if (test -e $basedir/avail/$2) {
29-			ln -sf $basedir/avail/$2 $basedir/run/
30-		}
31-		if not {
32-			printf 'Service not found\n'
33-			exit 1
34-		}
35+	switch($#*) {
36+		case 1
37+			find $basedir/run -type l
38+		case 2
39+			if (test -e $basedir/avail/$2) {
40+				ln -sf $basedir/avail/$2 $basedir/run/
41+			}
42+			if not {
43+				printf 'Service not found\n'
44+				exit 1
45+			}
46 	}
47 case -c
48 	test -d $basedir/run || mkdir -p $basedir/run