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
@@ -50,31 +50,21 @@ int debug_level;
50int prefix_key = META; 50int prefix_key = META;
51u_char status_colour; 51u_char status_colour;
52u_int history_limit; 52u_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
78logfile(const char *name) 68logfile(const char *name)
79{ 69{
80 FILE *f; 70 FILE *f;
@@ -199,19 +189,19 @@ main(int argc, char **argv)
199 debug_level++; 189 debug_level++;
200 break; 190 break;
201 case 'V': 191 case 'V':
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();
215 205
216 status_lines = 1; 206 status_lines = 1;
217 status_colour = 0x02; 207 status_colour = 0x02;
@@ -272,14 +262,12 @@ main(int argc, char **argv)
272 if (shell == NULL || *shell == '\0') 262 if (shell == NULL || *shell == '\0')
273 shell = _PATH_BSHELL; 263 shell = _PATH_BSHELL;
274 } 264 }
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 }
283 271
284 memset(&cctx, 0, sizeof cctx); 272 memset(&cctx, 0, sizeof cctx);
285 client_fill_session(&data); 273 client_fill_session(&data);
@@ -351,12 +339,7 @@ out:
351 buffer_destroy(cctx.srv_out); 339 buffer_destroy(cctx.srv_out);
352 340
353#ifdef DEBUG 341#ifdef DEBUG
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}