]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - builtin/help.c
The sixth batch
[thirdparty/git.git] / builtin / help.c
... / ...
CommitLineData
1/*
2 * Builtin help command
3 */
4
5#define USE_THE_REPOSITORY_VARIABLE
6
7#include "builtin.h"
8#include "config.h"
9#include "exec-cmd.h"
10#include "gettext.h"
11#include "pager.h"
12#include "parse-options.h"
13#include "path.h"
14#include "run-command.h"
15#include "config-list.h"
16#include "help.h"
17#include "alias.h"
18#include "setup.h"
19
20#ifndef DEFAULT_HELP_FORMAT
21#define DEFAULT_HELP_FORMAT "man"
22#endif
23
24static struct man_viewer_list {
25 struct man_viewer_list *next;
26 char name[FLEX_ARRAY];
27} *man_viewer_list;
28
29static struct man_viewer_info_list {
30 struct man_viewer_info_list *next;
31 const char *info;
32 char name[FLEX_ARRAY];
33} *man_viewer_info_list;
34
35enum help_format {
36 HELP_FORMAT_NONE,
37 HELP_FORMAT_MAN,
38 HELP_FORMAT_INFO,
39 HELP_FORMAT_WEB
40};
41
42enum show_config_type {
43 SHOW_CONFIG_HUMAN,
44 SHOW_CONFIG_VARS,
45 SHOW_CONFIG_SECTIONS,
46};
47
48static enum help_action {
49 HELP_ACTION_ALL = 1,
50 HELP_ACTION_GUIDES,
51 HELP_ACTION_CONFIG,
52 HELP_ACTION_USER_INTERFACES,
53 HELP_ACTION_DEVELOPER_INTERFACES,
54 HELP_ACTION_CONFIG_FOR_COMPLETION,
55 HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION,
56} cmd_mode;
57
58static char *html_path;
59static int verbose = 1;
60static enum help_format help_format = HELP_FORMAT_NONE;
61static int exclude_guides;
62static int show_external_commands = -1;
63static int show_aliases = -1;
64static struct option builtin_help_options[] = {
65 OPT_CMDMODE('a', "all", &cmd_mode, N_("print all available commands"),
66 HELP_ACTION_ALL),
67 OPT_BOOL(0, "external-commands", &show_external_commands,
68 N_("show external commands in --all")),
69 OPT_BOOL(0, "aliases", &show_aliases, N_("show aliases in --all")),
70 OPT_HIDDEN_BOOL(0, "exclude-guides", &exclude_guides, N_("exclude guides")),
71 OPT_SET_INT('m', "man", &help_format, N_("show man page"), HELP_FORMAT_MAN),
72 OPT_SET_INT('w', "web", &help_format, N_("show manual in web browser"),
73 HELP_FORMAT_WEB),
74 OPT_SET_INT('i', "info", &help_format, N_("show info page"),
75 HELP_FORMAT_INFO),
76 OPT__VERBOSE(&verbose, N_("print command description")),
77
78 OPT_CMDMODE('g', "guides", &cmd_mode, N_("print list of useful guides"),
79 HELP_ACTION_GUIDES),
80 OPT_CMDMODE(0, "user-interfaces", &cmd_mode,
81 N_("print list of user-facing repository, command and file interfaces"),
82 HELP_ACTION_USER_INTERFACES),
83 OPT_CMDMODE(0, "developer-interfaces", &cmd_mode,
84 N_("print list of file formats, protocols and other developer interfaces"),
85 HELP_ACTION_DEVELOPER_INTERFACES),
86 OPT_CMDMODE('c', "config", &cmd_mode, N_("print all configuration variable names"),
87 HELP_ACTION_CONFIG),
88 OPT_CMDMODE_F(0, "config-for-completion", &cmd_mode, "",
89 HELP_ACTION_CONFIG_FOR_COMPLETION, PARSE_OPT_HIDDEN),
90 OPT_CMDMODE_F(0, "config-sections-for-completion", &cmd_mode, "",
91 HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION, PARSE_OPT_HIDDEN),
92
93 OPT_END(),
94};
95
96static const char * const builtin_help_usage[] = {
97 "git help [-a|--all] [--[no-]verbose] [--[no-]external-commands] [--[no-]aliases]",
98 N_("git help [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>]"),
99 "git help [-g|--guides]",
100 "git help [-c|--config]",
101 "git help [--user-interfaces]",
102 "git help [--developer-interfaces]",
103 NULL
104};
105
106struct slot_expansion {
107 const char *prefix;
108 const char *placeholder;
109 void (*fn)(struct string_list *list, const char *prefix);
110 int found;
111};
112
113static void list_config_help(enum show_config_type type)
114{
115 struct slot_expansion slot_expansions[] = {
116 { "advice", "*", list_config_advices },
117 { "color.branch", "<slot>", list_config_color_branch_slots },
118 { "color.decorate", "<slot>", list_config_color_decorate_slots },
119 { "color.diff", "<slot>", list_config_color_diff_slots },
120 { "color.grep", "<slot>", list_config_color_grep_slots },
121 { "color.interactive", "<slot>", list_config_color_interactive_slots },
122 { "color.remote", "<slot>", list_config_color_sideband_slots },
123 { "color.status", "<slot>", list_config_color_status_slots },
124 { "fsck", "<msg-id>", list_config_fsck_msg_ids },
125 { "receive.fsck", "<msg-id>", list_config_fsck_msg_ids },
126 { NULL, NULL, NULL }
127 };
128 const char **p;
129 struct slot_expansion *e;
130 struct string_list keys = STRING_LIST_INIT_DUP;
131 struct string_list keys_uniq = STRING_LIST_INIT_DUP;
132 struct string_list_item *item;
133
134 for (p = config_name_list; *p; p++) {
135 const char *var = *p;
136 struct strbuf sb = STRBUF_INIT;
137
138 for (e = slot_expansions; e->prefix; e++) {
139
140 strbuf_reset(&sb);
141 strbuf_addf(&sb, "%s.%s", e->prefix, e->placeholder);
142 if (!strcasecmp(var, sb.buf)) {
143 e->fn(&keys, e->prefix);
144 e->found++;
145 break;
146 }
147 }
148 strbuf_release(&sb);
149 if (!e->prefix)
150 string_list_append(&keys, var);
151 }
152
153 for (e = slot_expansions; e->prefix; e++)
154 if (!e->found)
155 BUG("slot_expansion %s.%s is not used",
156 e->prefix, e->placeholder);
157
158 string_list_sort(&keys);
159 for (size_t i = 0; i < keys.nr; i++) {
160 const char *var = keys.items[i].string;
161 const char *wildcard, *tag, *cut;
162 const char *dot = NULL;
163 struct strbuf sb = STRBUF_INIT;
164
165 switch (type) {
166 case SHOW_CONFIG_HUMAN:
167 puts(var);
168 continue;
169 case SHOW_CONFIG_SECTIONS:
170 dot = strchr(var, '.');
171 break;
172 case SHOW_CONFIG_VARS:
173 break;
174 }
175 wildcard = strchr(var, '*');
176 tag = strchr(var, '<');
177
178 if (!dot && !wildcard && !tag) {
179 string_list_append(&keys_uniq, var);
180 continue;
181 }
182
183 if (dot)
184 cut = dot;
185 else if (wildcard && !tag)
186 cut = wildcard;
187 else if (!wildcard && tag)
188 cut = tag;
189 else
190 cut = wildcard < tag ? wildcard : tag;
191
192 strbuf_add(&sb, var, cut - var);
193 string_list_append(&keys_uniq, sb.buf);
194 strbuf_release(&sb);
195
196 }
197 string_list_clear(&keys, 0);
198 string_list_remove_duplicates(&keys_uniq, 0);
199 for_each_string_list_item(item, &keys_uniq)
200 puts(item->string);
201 string_list_clear(&keys_uniq, 0);
202}
203
204static enum help_format parse_help_format(const char *format)
205{
206 if (!strcmp(format, "man"))
207 return HELP_FORMAT_MAN;
208 if (!strcmp(format, "info"))
209 return HELP_FORMAT_INFO;
210 if (!strcmp(format, "web") || !strcmp(format, "html"))
211 return HELP_FORMAT_WEB;
212 /*
213 * Please update _git_config() in git-completion.bash when you
214 * add new help formats.
215 */
216 die(_("unrecognized help format '%s'"), format);
217}
218
219static const char *get_man_viewer_info(const char *name)
220{
221 struct man_viewer_info_list *viewer;
222
223 for (viewer = man_viewer_info_list; viewer; viewer = viewer->next)
224 {
225 if (!strcasecmp(name, viewer->name))
226 return viewer->info;
227 }
228 return NULL;
229}
230
231static int check_emacsclient_version(void)
232{
233 struct strbuf buffer = STRBUF_INIT;
234 struct child_process ec_process = CHILD_PROCESS_INIT;
235 int version;
236
237 /* emacsclient prints its version number on stderr */
238 strvec_pushl(&ec_process.args, "emacsclient", "--version", NULL);
239 ec_process.err = -1;
240 ec_process.stdout_to_stderr = 1;
241 if (start_command(&ec_process))
242 return error(_("Failed to start emacsclient."));
243
244 strbuf_read(&buffer, ec_process.err, 20);
245 close(ec_process.err);
246
247 /*
248 * Don't bother checking return value, because "emacsclient --version"
249 * seems to always exits with code 1.
250 */
251 finish_command(&ec_process);
252
253 if (!starts_with(buffer.buf, "emacsclient")) {
254 strbuf_release(&buffer);
255 return error(_("Failed to parse emacsclient version."));
256 }
257
258 strbuf_remove(&buffer, 0, strlen("emacsclient"));
259 version = atoi(buffer.buf);
260
261 if (version < 22) {
262 strbuf_release(&buffer);
263 return error(_("emacsclient version '%d' too old (< 22)."),
264 version);
265 }
266
267 strbuf_release(&buffer);
268 return 0;
269}
270
271static void exec_woman_emacs(const char *path, const char *page)
272{
273 if (!check_emacsclient_version()) {
274 /* This works only with emacsclient version >= 22. */
275 struct strbuf man_page = STRBUF_INIT;
276
277 if (!path)
278 path = "emacsclient";
279 strbuf_addf(&man_page, "(woman \"%s\")", page);
280 execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL);
281 warning_errno(_("failed to exec '%s'"), path);
282 strbuf_release(&man_page);
283 }
284}
285
286static void exec_man_konqueror(const char *path, const char *page)
287{
288 const char *display = getenv("DISPLAY");
289 if (display && *display) {
290 struct strbuf man_page = STRBUF_INIT;
291 const char *filename = "kfmclient";
292
293 /* It's simpler to launch konqueror using kfmclient. */
294 if (path) {
295 size_t len;
296 if (strip_suffix(path, "/konqueror", &len))
297 path = xstrfmt("%.*s/kfmclient", (int)len, path);
298 filename = basename((char *)path);
299 } else
300 path = "kfmclient";
301 strbuf_addf(&man_page, "man:%s(1)", page);
302 execlp(path, filename, "newTab", man_page.buf, (char *)NULL);
303 warning_errno(_("failed to exec '%s'"), path);
304 strbuf_release(&man_page);
305 }
306}
307
308static void exec_man_man(const char *path, const char *page)
309{
310 if (!path)
311 path = "man";
312 execlp(path, "man", page, (char *)NULL);
313 warning_errno(_("failed to exec '%s'"), path);
314}
315
316static void exec_man_cmd(const char *cmd, const char *page)
317{
318 struct strbuf shell_cmd = STRBUF_INIT;
319 strbuf_addf(&shell_cmd, "%s %s", cmd, page);
320 execl(SHELL_PATH, SHELL_PATH, "-c", shell_cmd.buf, (char *)NULL);
321 warning(_("failed to exec '%s'"), cmd);
322 strbuf_release(&shell_cmd);
323}
324
325static void add_man_viewer(const char *name)
326{
327 struct man_viewer_list **p = &man_viewer_list;
328
329 while (*p)
330 p = &((*p)->next);
331 FLEX_ALLOC_STR(*p, name, name);
332}
333
334static int supported_man_viewer(const char *name, size_t len)
335{
336 return (!strncasecmp("man", name, len) ||
337 !strncasecmp("woman", name, len) ||
338 !strncasecmp("konqueror", name, len));
339}
340
341static void do_add_man_viewer_info(const char *name,
342 size_t len,
343 const char *value)
344{
345 struct man_viewer_info_list *new_man_viewer;
346 FLEX_ALLOC_MEM(new_man_viewer, name, name, len);
347 new_man_viewer->info = xstrdup(value);
348 new_man_viewer->next = man_viewer_info_list;
349 man_viewer_info_list = new_man_viewer;
350}
351
352static int add_man_viewer_path(const char *name,
353 size_t len,
354 const char *value)
355{
356 if (supported_man_viewer(name, len))
357 do_add_man_viewer_info(name, len, value);
358 else
359 warning(_("'%s': path for unsupported man viewer.\n"
360 "Please consider using 'man.<tool>.cmd' instead."),
361 name);
362
363 return 0;
364}
365
366static int add_man_viewer_cmd(const char *name,
367 size_t len,
368 const char *value)
369{
370 if (supported_man_viewer(name, len))
371 warning(_("'%s': cmd for supported man viewer.\n"
372 "Please consider using 'man.<tool>.path' instead."),
373 name);
374 else
375 do_add_man_viewer_info(name, len, value);
376
377 return 0;
378}
379
380static int add_man_viewer_info(const char *var, const char *value)
381{
382 const char *name, *subkey;
383 size_t namelen;
384
385 if (parse_config_key(var, "man", &name, &namelen, &subkey) < 0 || !name)
386 return 0;
387
388 if (!strcmp(subkey, "path")) {
389 if (!value)
390 return config_error_nonbool(var);
391 return add_man_viewer_path(name, namelen, value);
392 }
393 if (!strcmp(subkey, "cmd")) {
394 if (!value)
395 return config_error_nonbool(var);
396 return add_man_viewer_cmd(name, namelen, value);
397 }
398
399 return 0;
400}
401
402static int git_help_config(const char *var, const char *value,
403 const struct config_context *ctx, void *cb)
404{
405 if (!strcmp(var, "help.format")) {
406 if (!value)
407 return config_error_nonbool(var);
408 help_format = parse_help_format(value);
409 return 0;
410 }
411 if (!strcmp(var, "help.htmlpath")) {
412 if (!value)
413 return config_error_nonbool(var);
414 free(html_path);
415 html_path = xstrdup(value);
416 return 0;
417 }
418 if (!strcmp(var, "man.viewer")) {
419 if (!value)
420 return config_error_nonbool(var);
421 add_man_viewer(value);
422 return 0;
423 }
424 if (starts_with(var, "man."))
425 return add_man_viewer_info(var, value);
426
427 return git_default_config(var, value, ctx, cb);
428}
429
430static struct cmdnames main_cmds, other_cmds;
431
432static int is_git_command(const char *s)
433{
434 if (is_builtin(s))
435 return 1;
436
437 load_command_list("git-", &main_cmds, &other_cmds);
438 return is_in_cmdlist(&main_cmds, s) ||
439 is_in_cmdlist(&other_cmds, s);
440}
441
442static const char *cmd_to_page(const char *git_cmd)
443{
444 if (!git_cmd)
445 return "git";
446 else if (starts_with(git_cmd, "git"))
447 return git_cmd;
448 else if (is_git_command(git_cmd))
449 return xstrfmt("git-%s", git_cmd);
450 else if (!strcmp("scalar", git_cmd))
451 return xstrdup(git_cmd);
452 else
453 return xstrfmt("git%s", git_cmd);
454}
455
456static void setup_man_path(void)
457{
458 struct strbuf new_path = STRBUF_INIT;
459 const char *old_path = getenv("MANPATH");
460 char *git_man_path = system_path(GIT_MAN_PATH);
461
462 /* We should always put ':' after our path. If there is no
463 * old_path, the ':' at the end will let 'man' to try
464 * system-wide paths after ours to find the manual page. If
465 * there is old_path, we need ':' as delimiter. */
466 strbuf_addstr(&new_path, git_man_path);
467 strbuf_addch(&new_path, ':');
468 if (old_path)
469 strbuf_addstr(&new_path, old_path);
470
471 free(git_man_path);
472 setenv("MANPATH", new_path.buf, 1);
473
474 strbuf_release(&new_path);
475}
476
477static void exec_viewer(const char *name, const char *page)
478{
479 const char *info = get_man_viewer_info(name);
480
481 if (!strcasecmp(name, "man"))
482 exec_man_man(info, page);
483 else if (!strcasecmp(name, "woman"))
484 exec_woman_emacs(info, page);
485 else if (!strcasecmp(name, "konqueror"))
486 exec_man_konqueror(info, page);
487 else if (info)
488 exec_man_cmd(info, page);
489 else
490 warning(_("'%s': unknown man viewer."), name);
491}
492
493static void show_man_page(const char *page)
494{
495 struct man_viewer_list *viewer;
496 const char *fallback = getenv("GIT_MAN_VIEWER");
497
498 setup_man_path();
499 for (viewer = man_viewer_list; viewer; viewer = viewer->next)
500 {
501 exec_viewer(viewer->name, page); /* will return when unable */
502 }
503 if (fallback)
504 exec_viewer(fallback, page);
505 exec_viewer("man", page);
506 die(_("no man viewer handled the request"));
507}
508
509static void show_info_page(const char *page)
510{
511 setenv("INFOPATH", system_path(GIT_INFO_PATH), 1);
512 execlp("info", "info", "gitman", page, (char *)NULL);
513 die(_("no info viewer handled the request"));
514}
515
516static void get_html_page_path(struct strbuf *page_path, const char *page)
517{
518 struct stat st;
519 const char *path = html_path;
520 char *to_free = NULL;
521
522 if (!path)
523 path = to_free = system_path(GIT_HTML_PATH);
524
525 /*
526 * Check that the page we're looking for exists.
527 */
528 if (!strstr(path, "://")) {
529 if (stat(mkpath("%s/%s.html", path, page), &st)
530 || !S_ISREG(st.st_mode))
531 die("'%s/%s.html': documentation file not found.",
532 path, page);
533 }
534
535 strbuf_init(page_path, 0);
536 strbuf_addf(page_path, "%s/%s.html", path, page);
537 free(to_free);
538}
539
540static void open_html(const char *path)
541{
542 execl_git_cmd("web--browse", "-c", "help.browser", path, (char *)NULL);
543}
544
545static void show_html_page(const char *page)
546{
547 struct strbuf page_path; /* it leaks but we exec below */
548
549 get_html_page_path(&page_path, page);
550
551 open_html(page_path.buf);
552}
553
554static char *check_git_cmd(const char *cmd)
555{
556 char *alias;
557
558 if (is_git_command(cmd))
559 return xstrdup(cmd);
560
561 alias = alias_lookup(cmd);
562 if (alias) {
563 const char **argv;
564 int count;
565
566 /*
567 * handle_builtin() in git.c rewrites "git cmd --help"
568 * to "git help --exclude-guides cmd", so we can use
569 * exclude_guides to distinguish "git cmd --help" from
570 * "git help cmd". In the latter case, or if cmd is an
571 * alias for a shell command, just print the alias
572 * definition.
573 */
574 if (!exclude_guides || alias[0] == '!') {
575 printf_ln(_("'%s' is aliased to '%s'"), cmd, alias);
576 free(alias);
577 exit(0);
578 }
579 /*
580 * Otherwise, we pretend that the command was "git
581 * word0 --help". We use split_cmdline() to get the
582 * first word of the alias, to ensure that we use the
583 * same rules as when the alias is actually
584 * used. split_cmdline() modifies alias in-place.
585 */
586 fprintf_ln(stderr, _("'%s' is aliased to '%s'"), cmd, alias);
587 count = split_cmdline(alias, &argv);
588 if (count < 0)
589 die(_("bad alias.%s string: %s"), cmd,
590 split_cmdline_strerror(count));
591 free(argv);
592 return alias;
593 }
594
595 if (exclude_guides)
596 return help_unknown_cmd(cmd);
597
598 return xstrdup(cmd);
599}
600
601static void no_help_format(const char *opt_mode, enum help_format fmt)
602{
603 const char *opt_fmt;
604
605 switch (fmt) {
606 case HELP_FORMAT_NONE:
607 return;
608 case HELP_FORMAT_MAN:
609 opt_fmt = "--man";
610 break;
611 case HELP_FORMAT_INFO:
612 opt_fmt = "--info";
613 break;
614 case HELP_FORMAT_WEB:
615 opt_fmt = "--web";
616 break;
617 default:
618 BUG("unreachable");
619 }
620
621 usage_msg_optf(_("options '%s' and '%s' cannot be used together"),
622 builtin_help_usage, builtin_help_options, opt_mode,
623 opt_fmt);
624}
625
626static void opt_mode_usage(int argc, const char *opt_mode,
627 enum help_format fmt)
628{
629 if (argc)
630 usage_msg_optf(_("the '%s' option doesn't take any non-option arguments"),
631 builtin_help_usage, builtin_help_options,
632 opt_mode);
633
634 no_help_format(opt_mode, fmt);
635}
636
637int cmd_help(int argc,
638 const char **argv,
639 const char *prefix,
640 struct repository *repo UNUSED)
641{
642 int nongit;
643 enum help_format parsed_help_format;
644 char *command = NULL;
645 const char *page;
646
647 argc = parse_options(argc, argv, prefix, builtin_help_options,
648 builtin_help_usage, 0);
649 parsed_help_format = help_format;
650
651 if (cmd_mode != HELP_ACTION_ALL &&
652 (show_external_commands >= 0 ||
653 show_aliases >= 0))
654 usage_msg_opt(_("the '--no-[external-commands|aliases]' options can only be used with '--all'"),
655 builtin_help_usage, builtin_help_options);
656
657 switch (cmd_mode) {
658 case HELP_ACTION_ALL:
659 opt_mode_usage(argc, "--all", help_format);
660 if (verbose) {
661 setup_pager(the_repository);
662 list_all_cmds_help(show_external_commands,
663 show_aliases);
664 return 0;
665 }
666 printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
667 load_command_list("git-", &main_cmds, &other_cmds);
668 list_commands(&main_cmds, &other_cmds);
669 printf("%s\n", _(git_more_info_string));
670 break;
671 case HELP_ACTION_GUIDES:
672 opt_mode_usage(argc, "--guides", help_format);
673 list_guides_help();
674 printf("%s\n", _(git_more_info_string));
675 return 0;
676 case HELP_ACTION_CONFIG_FOR_COMPLETION:
677 opt_mode_usage(argc, "--config-for-completion", help_format);
678 list_config_help(SHOW_CONFIG_VARS);
679 return 0;
680 case HELP_ACTION_USER_INTERFACES:
681 opt_mode_usage(argc, "--user-interfaces", help_format);
682 list_user_interfaces_help();
683 return 0;
684 case HELP_ACTION_DEVELOPER_INTERFACES:
685 opt_mode_usage(argc, "--developer-interfaces", help_format);
686 list_developer_interfaces_help();
687 return 0;
688 case HELP_ACTION_CONFIG_SECTIONS_FOR_COMPLETION:
689 opt_mode_usage(argc, "--config-sections-for-completion",
690 help_format);
691 list_config_help(SHOW_CONFIG_SECTIONS);
692 return 0;
693 case HELP_ACTION_CONFIG:
694 opt_mode_usage(argc, "--config", help_format);
695 setup_pager(the_repository);
696 list_config_help(SHOW_CONFIG_HUMAN);
697 printf("\n%s\n", _("'git help config' for more information"));
698 return 0;
699 }
700
701 if (!argv[0]) {
702 printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
703 list_common_cmds_help();
704 printf("\n%s\n", _(git_more_info_string));
705 return 0;
706 }
707
708 setup_git_directory_gently(&nongit);
709 git_config(git_help_config, NULL);
710
711 if (parsed_help_format != HELP_FORMAT_NONE)
712 help_format = parsed_help_format;
713 if (help_format == HELP_FORMAT_NONE)
714 help_format = parse_help_format(DEFAULT_HELP_FORMAT);
715
716 command = check_git_cmd(argv[0]);
717
718 page = cmd_to_page(command);
719 switch (help_format) {
720 case HELP_FORMAT_NONE:
721 case HELP_FORMAT_MAN:
722 show_man_page(page);
723 break;
724 case HELP_FORMAT_INFO:
725 show_info_page(page);
726 break;
727 case HELP_FORMAT_WEB:
728 show_html_page(page);
729 break;
730 }
731
732 free(command);
733 return 0;
734}