summary refs log tree commit diff
diff options
context:
space:
mode:
authoroga <oga>2008-02-13 21:04:19 +0000
committeroga <oga>2008-02-13 21:04:19 +0000
commit9cb4f8884eb4f633d1d3983285aa1025c0ed7efc (patch)
tree88269096b640150eee4c9807a6601f63d1b2e03f
parent09dbddac8750b72eb00950b3f1a20c3fb81c6240 (diff)
downloadcwm-9cb4f8884eb4f633d1d3983285aa1025c0ed7efc.tar.gz
cwm-9cb4f8884eb4f633d1d3983285aa1025c0ed7efc.tar.xz
cwm-9cb4f8884eb4f633d1d3983285aa1025c0ed7efc.zip
add usage() for when an unknown option is given.
from Gleydson Soares <gsoares@gmail.com>, thanks!

ok jasper@
-rw-r--r--calmwm.c11
-rw-r--r--calmwm.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/calmwm.c b/calmwm.c
index 886ee32..7703221 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -71,7 +71,7 @@ main(int argc, char **argv)
 			DefaultFontName = xstrdup(optarg);
 			break;
 		default:
-			errx(1, "Unknown option '%c'", ch);
+			usage();
 		}
 	}
 	argc -= optind;
@@ -321,3 +321,12 @@ _sigchld_cb(int which)
             (pid < 0 && errno == EINTR))
 		;
 }
+
+void
+usage(void)
+{
+	extern char *__progname;
+
+	fprintf(stderr, "usage: %s [-s] [-d display] [-f fontname] \n", __progname);
+	exit(1);
+}
diff --git a/calmwm.h b/calmwm.h
index e4f463d..4c58df0 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -312,6 +312,7 @@ int   x_errorhandler(Display *, XErrorEvent *);
 void  x_setup(char *display_name);
 char *x_screenname(int);
 void  x_setupscreen(struct screen_ctx *, u_int);
+void  usage(void);
 
 struct client_ctx *client_find(Window);
 void               client_setup(void);