csh and tcsh work

Sources of csh/sh.init.c

csh と tcsh のソース

Bill Joy

First published: October, 1978.

Copyright © 1979 Regents of the University of California.

  1. 1
    /* Copyright (c) 1979 Regents of the University of California */
  2. 2
    #include "sh.local.h"
  3. 3
    /*
  4. 4
     * C shell
  5. 5
     */
  6. 6
  7. 7
    extern	int await();
  8. 8
    extern	int chngd();
  9. 9
    extern	int doalias();
  10. 10
    extern	int dobreak();
  11. 11
    extern	int docontin();
  12. 12
    extern	int doecho();
  13. 13
    extern	int doelse();
  14. 14
    extern	int doend();
  15. 15
    extern	int doendif();
  16. 16
    extern	int doendsw();
  17. 17
    extern	int doexit();
  18. 18
    extern	int doforeach();
  19. 19
    extern	int doglob();
  20. 20
    extern	int dogoto();
  21. 21
    extern	int dohist();
  22. 22
    extern	int doif();
  23. 23
    extern	int dolet();
  24. 24
    extern	int dologout();
  25. 25
    extern	int donice();
  26. 26
    extern	int donohup();
  27. 27
    extern	int doonintr();
  28. 28
    extern	int dorepeat();
  29. 29
    extern	int doset();
  30. 30
    extern	int dosetenv();
  31. 31
    extern	int dosource();
  32. 32
    extern	int doswbrk();
  33. 33
    extern	int doswitch();
  34. 34
    extern	int dotime();
  35. 35
    #ifndef V6
  36. 36
    extern	int doumask();
  37. 37
    #endif
  38. 38
    extern	int dowhile();
  39. 39
    extern	int dozip();
  40. 40
    extern	int execash();
  41. 41
    extern	int goodbye();
  42. 42
    extern	int shift();
  43. 43
    extern	int showall();
  44. 44
    extern	int unalias();
  45. 45
    extern	int unset();
  46. 46
  47. 47
    #define INF	1000
  48. 48
  49. 49
    struct	biltins {
  50. 50
    	char	*bname;
  51. 51
    	int	(*bfunct)();
  52. 52
    	short	minargs, maxargs;
  53. 53
    } bfunc[] = {
  54. 54
    	"@",		dolet,		0,	INF,
  55. 55
    	"alias",	doalias,	0,	INF,
  56. 56
    #ifdef debug
  57. 57
    	"alloc",	showall,	0,	1,
  58. 58
    #endif
  59. 59
    	"break",	dobreak,	0,	0,
  60. 60
    	"breaksw",	doswbrk,	0,	0,
  61. 61
    	"case",		dozip,		0,	1,
  62. 62
    	"cd",		chngd,		0,	1,
  63. 63
    	"chdir",	chngd,		0,	1,
  64. 64
    	"continue",	docontin,	0,	0,
  65. 65
    	"default",	dozip,		0,	0,
  66. 66
    	"echo",		doecho,		0,	INF,
  67. 67
    	"else",		doelse,		0,	INF,
  68. 68
    	"end",		doend,		0,	0,
  69. 69
    	"endif",	dozip,		0,	0,
  70. 70
    	"endsw",	dozip,		0,	0,
  71. 71
    	"exec",		execash,	1,	INF,
  72. 72
    	"exit",		doexit,		0,	INF,
  73. 73
    	"foreach",	doforeach,	3,	INF,
  74. 74
    	"glob",		doglob,		0,	INF,
  75. 75
    	"goto",		dogoto,		1,	1,
  76. 76
    	"history",	dohist,		0,	0,
  77. 77
    	"if",		doif,		1,	INF,
  78. 78
    	"logout",	dologout,	0,	0,
  79. 79
    	"nice",		donice,		0,	INF,
  80. 80
    	"nohup",	donohup,	0,	INF,
  81. 81
    	"onintr",	doonintr,	0,	2,
  82. 82
    	"repeat",	dorepeat,	2,	INF,
  83. 83
    	"set",		doset,		0,	INF,
  84. 84
    #ifndef V6
  85. 85
    	"setenv",	dosetenv,	2,	2,
  86. 86
    #endif
  87. 87
    	"shift",	shift,		0,	1,
  88. 88
    	"source",	dosource,	1,	1,
  89. 89
    	"switch",	doswitch,	1,	INF,
  90. 90
    	"time",		dotime,		0,	INF,
  91. 91
    #ifndef V6
  92. 92
    	"umask",	doumask,	0,	1,
  93. 93
    #endif
  94. 94
    	"unalias",	unalias,	1,	INF,
  95. 95
    	"unset",	unset,		1,	INF,
  96. 96
    	"wait",		await,		0,	0,
  97. 97
    	"while",	dowhile,	1,	INF,
  98. 98
    	0,		0,		0,	0,
  99. 99
    };
  100. 100
  101. 101
    #define	ZBREAK		0
  102. 102
    #define	ZBRKSW		1
  103. 103
    #define	ZCASE		2
  104. 104
    #define	ZDEFAULT 	3
  105. 105
    #define	ZELSE		4
  106. 106
    #define	ZEND		5
  107. 107
    #define	ZENDIF		6
  108. 108
    #define	ZENDSW		7
  109. 109
    #define	ZEXIT		8
  110. 110
    #define	ZFOREACH	9
  111. 111
    #define	ZGOTO		10
  112. 112
    #define	ZIF		11
  113. 113
    #define	ZLABEL		12
  114. 114
    #define	ZLET		13
  115. 115
    #define	ZSET		14
  116. 116
    #define	ZSWITCH		15
  117. 117
    #define	ZTEST		16
  118. 118
    #define	ZTHEN		17
  119. 119
    #define	ZWHILE		18
  120. 120
  121. 121
    struct srch {
  122. 122
    	char	*s_name;
  123. 123
    	short	s_value;
  124. 124
    } srchn[] = {
  125. 125
    	"@",		ZLET,
  126. 126
    	"break",	ZBREAK,
  127. 127
    	"breaksw",	ZBRKSW,
  128. 128
    	"case",		ZCASE,
  129. 129
    	"default", 	ZDEFAULT,
  130. 130
    	"else",		ZELSE,
  131. 131
    	"end",		ZEND,
  132. 132
    	"endif",	ZENDIF,
  133. 133
    	"endsw",	ZENDSW,
  134. 134
    	"exit",		ZEXIT,
  135. 135
    	"foreach", 	ZFOREACH,
  136. 136
    	"goto",		ZGOTO,
  137. 137
    	"if",		ZIF,
  138. 138
    	"label",	ZLABEL,
  139. 139
    	"set",		ZSET,
  140. 140
    	"switch",	ZSWITCH,
  141. 141
    	"while",	ZWHILE,
  142. 142
    	0,		0,
  143. 143
    };
  144. 144
  145. 145
    char	*mesg[] = {
  146. 146
    	0,
  147. 147
    	"Hangup",
  148. 148
    	0,
  149. 149
    	"Quit",
  150. 150
    	"Illegal instruction",
  151. 151
    	"Trace/BPT trap",
  152. 152
    	"IOT trap",
  153. 153
    	"EMT trap",
  154. 154
    	"Floating exception",
  155. 155
    	"Killed",
  156. 156
    	"Bus error",
  157. 157
    	"Segmentation violation",
  158. 158
    	"Bad system call",
  159. 159
    	0,
  160. 160
    	"Alarm clock",
  161. 161
    	"Terminated",
  162. 162
    };

To the top of this page