aboutsummaryrefslogtreecommitdiff
path: root/test/functional/fixtures/shell-test.c
blob: 5fa8a5804926fe902799a950c5df4f3016f87682 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// A simple implementation of a shell for testing
// `termopen([&sh, &shcf, '{cmd'}])` and `termopen([&sh])`.
//
// If launched with no arguments, prints "ready $ ", otherwise prints
// "ready $ {cmd}\n".

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
  fprintf(stderr, "ready $ ");

  if (argc == 3) {
    // argv should be {"terminal-test", "EXE", "prog args..."}
    if (strcmp(argv[1], "EXE") != 0) {
      fprintf(stderr, "first argument must be 'EXE'\n");
      return 2;
    }

    fprintf(stderr, "%s\n", argv[2]);
  }

  return 0;
}