summaryrefslogtreecommitdiffstats
path: root/tmux.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmux.c')
-rw-r--r--tmux.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/tmux.c b/tmux.c
index 98f0091d..ac0e7fbd 100644
--- a/tmux.c
+++ b/tmux.c
@@ -53,25 +53,15 @@ u_int history_limit;
53u_int status_lines; 53u_int status_lines;
54 54
55void sighandler(int); 55void sighandler(int);
56__dead void usage(void);
56 57
57void 58__dead void
58usage(char **ptr, const char *fmt, ...) 59usage(void)
59{ 60{
60 char *msg; 61 fprintf(stderr,
61 va_list ap; 62 "usage: %s [-v] [-f file] [-S socket-path] command [flags]",
62 63 __progname);
63#define USAGE "usage: %s [-v] [-f file] [-S socket-path]" 64 exit(1);
64 if (fmt == NULL) {
65 xasprintf(ptr, USAGE " command [flags]", __progname);
66 } else {
67 va_start(ap, fmt);
68 xvasprintf(&msg, fmt, ap);
69 va_end(ap);
70
71 xasprintf(ptr, USAGE " %s", __progname, msg);
72 xfree(msg);
73 }
74#undef USAGE
75} 65}
76 66
77void 67void
@@ -202,13 +192,13 @@ main(int argc, char **argv)
202 printf("%s " BUILD "\n", __progname); 192 printf("%s " BUILD "\n", __progname);
203 exit(0); 193 exit(0);
204 default: 194 default:
205 goto usage; 195 usage();
206 } 196 }
207 } 197 }
208 argc -= optind; 198 argc -= optind;
209 argv += optind; 199 argv += optind;
210 if (argc == 0) 200 if (argc == 0)
211 goto usage; 201 usage();
212 202
213 log_open(stderr, LOG_USER, debug_level); 203 log_open(stderr, LOG_USER, debug_level);
214 siginit(); 204 siginit();
@@ -275,8 +265,6 @@ main(int argc, char **argv)
275 xasprintf(&default_command, "exec %s", shell); 265 xasprintf(&default_command, "exec %s", shell);
276 266
277 if ((cmd = cmd_parse(argc, argv, &cause)) == NULL) { 267 if ((cmd = cmd_parse(argc, argv, &cause)) == NULL) {
278 if (cause == NULL)
279 goto usage;
280 log_warnx("%s", cause); 268 log_warnx("%s", cause);
281 exit(1); 269 exit(1);
282 } 270 }
@@ -354,9 +342,4 @@ out:
354 xmalloc_report(getpid(), "client"); 342 xmalloc_report(getpid(), "client");
355#endif 343#endif
356 return (n); 344 return (n);
357
358usage:
359 usage(&cause, NULL);
360 fprintf(stderr, "%s\n", cause);
361 exit(1);
362} 345}