]>
Commit | Line | Data |
---|---|---|
3064d5a3 JS |
1 | #include "git-compat-util.h" |
2 | #include "run-command.h" | |
3 | #include "strbuf.h" | |
4 | ||
3f2e2297 | 5 | int cmd_main(int argc, const char **argv) |
3064d5a3 JS |
6 | { |
7 | const char *trash_directory = getenv("TRASH_DIRECTORY"); | |
8 | struct strbuf buf = STRBUF_INIT; | |
9 | FILE *f; | |
10 | int i; | |
4120294c | 11 | struct child_process cmd = CHILD_PROCESS_INIT; |
3064d5a3 JS |
12 | |
13 | /* First, print all parameters into $TRASH_DIRECTORY/ssh-output */ | |
14 | if (!trash_directory) | |
15 | die("Need a TRASH_DIRECTORY!"); | |
16 | strbuf_addf(&buf, "%s/ssh-output", trash_directory); | |
17 | f = fopen(buf.buf, "w"); | |
18 | if (!f) | |
19 | die("Could not write to %s", buf.buf); | |
b6046abc | 20 | strbuf_release(&buf); |
3064d5a3 JS |
21 | for (i = 0; i < argc; i++) |
22 | fprintf(f, "%s%s", i > 0 ? " " : "", i > 0 ? argv[i] : "ssh:"); | |
23 | fprintf(f, "\n"); | |
24 | fclose(f); | |
25 | ||
26 | /* Now, evaluate the *last* parameter */ | |
27 | if (argc < 2) | |
28 | return 0; | |
4120294c RS |
29 | cmd.use_shell = 1; |
30 | strvec_push(&cmd.args, argv[argc - 1]); | |
31 | return run_command(&cmd); | |
3064d5a3 | 32 | } |