summary refs log tree commit diff
path: root/bin/pbd.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/pbd.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/bin/pbd.c b/bin/pbd.c
index 58326053..9f47b63e 100644
--- a/bin/pbd.c
+++ b/bin/pbd.c
@@ -138,15 +138,14 @@ static int open1(const char *url) {
 }
 
 int main(int argc, char *argv[]) {
-	(void)argc;
-	if (strchr(argv[0], '/')) {
-		argv[0] = strrchr(argv[0], '/') + 1;
-	}
-	switch (argv[0][0] && argv[0][1] ? argv[0][2] : 0) {
-		case 'd': return pbd();
-		case 'c': return pbcopy();
-		case 'p': return pbpaste();
-		case 'e': return open1(argv[1]);
-		default:  return EX_USAGE;
+	for (int opt; 0 < (opt = getopt(argc, argv, "co:ps"));) {
+		switch (opt) {
+			case 'c': return pbcopy();
+			case 'o': return open1(optarg);
+			case 'p': return pbpaste();
+			case 's': return pbd();
+			default:  return EX_USAGE;
+		}
 	}
+	return pbd();
 }