1 |
douglas |
562 |
// Douglas Thrift |
2 |
|
|
// |
3 |
|
|
// CCS Computer Science |
4 |
|
|
// |
5 |
|
|
// Change Shell |
6 |
|
|
|
7 |
|
|
#include <sys/utsname.h> |
8 |
|
|
|
9 |
|
|
#include "common.h" |
10 |
|
|
|
11 |
|
|
int main(int argc, char *argv[]) |
12 |
|
|
{ |
13 |
|
|
int exception; |
14 |
|
|
jmp_buf environment; |
15 |
|
|
|
16 |
|
|
switch (exception = setjmp(environment)) |
17 |
|
|
{ |
18 |
|
|
case 0: |
19 |
|
|
break; |
20 |
|
|
case 1: |
21 |
|
|
perror(argv[0]); |
22 |
|
|
|
23 |
|
|
return 1; |
24 |
|
|
default: |
25 |
|
|
fprintf(stderr, "%s: %s\n", argv[0], (char *)exception); |
26 |
|
|
|
27 |
|
|
return 1; |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
typedef struct |
31 |
|
|
{ |
32 |
|
|
const char *name; |
33 |
|
|
char *freebsd, *linux, *darwin; |
34 |
|
|
} |
35 |
|
|
Shell; |
36 |
|
|
|
37 |
|
|
typedef enum { sh, csh, tcsh, bash, ksh, zsh, _3sh, custom } Shells; |
38 |
|
|
|
39 |
|
|
Shell shells[] = { |
40 |
|
|
{ "sh", "/bin/sh", "/bin/sh", "/bin/sh" }, |
41 |
|
|
{ "csh", "/bin/csh", "/bin/csh", "/bin/csh" }, |
42 |
|
|
{ "tcsh", "/bin/tcsh", "/bin/tcsh", "/bin/tcsh" }, |
43 |
|
|
{ "bash", "/usr/local/bin/bash", "/bin/bash", "/bin/bash" }, |
44 |
|
|
{ "ksh", "/usr/local/bin/ksh", "/bin/ksh", "/bin/ksh" }, |
45 |
|
|
{ "zsh", "/usr/local/bin/zsh", "/bin/zsh", "/bin/zsh" }, |
46 |
|
|
{ "3sh", "/ccs/bin/3sh", "/ccs/bin/3sh", "/ccs/bin/3sh" }, |
47 |
|
|
{ "custom", NULL, NULL, NULL } |
48 |
|
|
}; |
49 |
|
|
|
50 |
|
|
for (Shells shell = sh; shell != custom; ++shell) |
51 |
|
|
printf("%s, ", shells[shell].name); |
52 |
|
|
|
53 |
|
|
printf("%s\n", shells[custom].name); |
54 |
|
|
|
55 |
|
|
return 0; |
56 |
|
|
} |