test-fake-ssh.con commit Merge branch 'ss/commit-squash-msg' into maint (ea7fefb)
   1#include "git-compat-util.h"
   2#include "run-command.h"
   3#include "strbuf.h"
   4
   5int main(int argc, char **argv)
   6{
   7        const char *trash_directory = getenv("TRASH_DIRECTORY");
   8        struct strbuf buf = STRBUF_INIT;
   9        FILE *f;
  10        int i;
  11        const char *child_argv[] = { NULL, NULL };
  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);
  20        for (i = 0; i < argc; i++)
  21                fprintf(f, "%s%s", i > 0 ? " " : "", i > 0 ? argv[i] : "ssh:");
  22        fprintf(f, "\n");
  23        fclose(f);
  24
  25        /* Now, evaluate the *last* parameter */
  26        if (argc < 2)
  27                return 0;
  28        child_argv[0] = argv[argc - 1];
  29        return run_command_v_opt(child_argv, RUN_USING_SHELL);
  30}