summary refs log tree commit diff
path: root/bin/pbd.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pbd.c')
-rw-r--r--bin/pbd.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/bin/pbd.c b/bin/pbd.c
index 2ba333fd..9f47b63e 100644
--- a/bin/pbd.c
+++ b/bin/pbd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2017  June McEnroe <june@causal.agency>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -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();
 }