const char *prog;
char *full_cmd;
char *rawargs;
+ char *split_args;
const char **argv;
int code;
+ int count;
fprintf(stderr, "git> ");
if (strbuf_getline(&line, stdin, '\n') == EOF) {
}
strbuf_trim(&line);
rawargs = strbuf_detach(&line, NULL);
- if (split_cmdline(rawargs, &argv) == -1) {
+ split_args = xstrdup(rawargs);
+ count = split_cmdline(split_args, &argv);
+ if (count < 0) {
+ fprintf(stderr, "invalid command format '%s': %s\n", rawargs,
+ split_cmdline_strerror(count));
+ free(split_args);
free(rawargs);
continue;
}
const char **user_argv;
struct commands *cmd;
int devnull_fd;
+ int count;
/*
* Always open file descriptors 0/1/2 to avoid clobbering files
} else if (argc == 1) {
/* Allow the user to run an interactive shell */
cd_to_homedir();
- if (access(COMMAND_DIR, R_OK | X_OK) == -1)
- die("Sorry, the interactive git-shell is not enabled");
+ if (access(COMMAND_DIR, R_OK | X_OK) == -1) {
+ die("Interactive git shell is not enabled.\n"
+ "hint: ~/" COMMAND_DIR " should exist "
+ "and have read and execute access.");
+ }
run_shell();
exit(0);
} else if (argc != 3 || strcmp(argv[1], "-c")) {
}
cd_to_homedir();
- if (split_cmdline(prog, &user_argv) != -1) {
+ count = split_cmdline(prog, &user_argv);
+ if (count >= 0) {
if (is_valid_cmd_name(user_argv[0])) {
prog = make_cmd(user_argv[0]);
user_argv[0] = prog;
die("unrecognized command '%s'", argv[2]);
} else {
free(prog);
- die("invalid command format '%s'", argv[2]);
+ die("invalid command format '%s': %s", argv[2],
+ split_cmdline_strerror(count));
}
}