home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume35 / zsh / part16 < prev    next >
Text File  |  1993-02-20  |  56KB  |  1,959 lines

  1. Newsgroups: comp.sources.misc
  2. From: zsh-list@cs.uow.edu.au (The Zsh Mailing List)
  3. Subject: v35i066:  zsh - The Z Shell, version 2.3.1, Part16/22
  4. Message-ID: <1993Feb20.212657.29208@sparky.imd.sterling.com>
  5. X-Md4-Signature: b887384bca352f9a0b413ad7c595f74f
  6. Date: Sat, 20 Feb 1993 21:26:57 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: zsh-list@cs.uow.edu.au (The Zsh Mailing List)
  10. Posting-number: Volume 35, Issue 66
  11. Archive-name: zsh/part16
  12. Environment: UNIX
  13. Supersedes: zsh2.2: Volume 29, Issue 97-113
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  src/buildzsh src/init.c src/zle_bindings.c
  22. # Wrapped by mattson@odin on Sat Feb  6 14:41:54 1993
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 16 (of 22)."'
  26. if test -f 'src/buildzsh' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'src/buildzsh'\"
  28. else
  29.   echo shar: Extracting \"'src/buildzsh'\" \(18846 characters\)
  30.   sed "s/^X//" >'src/buildzsh' <<'END_OF_FILE'
  31. X#! /bin/sh
  32. Xecho
  33. Xecho 'Trying to determine host type...'
  34. X
  35. Xheaderdir=/usr/include
  36. Xarch=`(uname) 2>/dev/null`
  37. Xcase "$arch" in
  38. X"")    case `(head -2 /etc/motd) 2>/dev/null` in
  39. X    *"HP-UX"*)    HPUX=yep; machid=hp9000;;
  40. X    *"Iris"*)    SGI=yep; host=iris4d;;
  41. X    *"Ultrix"*)    ULTRIX=yep; host=vax;;
  42. X    *"RISC iX"*)    ARM=yep; host=arm;;
  43. X    *"Umax 4.2"*)    ENCORE=yep; host=encore;;
  44. X    *"Alliant Concentrix"*) ALLIANT=yep; host=alliant;;
  45. X    *"FPS Model 500"*) FPS=yep; host=fps500;;
  46. X    *"HCX/UX"*)    HARRIS=yep; host=harris;;
  47. X    *"nX Operating System"*)    BBN=yep; host=`arch`;;
  48. X    *)
  49. X        if test -d ${headerdir}/caif
  50. X        then AIX=yep; host=ibm032
  51. X        elif test -d /sys/node_data
  52. X        then APOLLO=yep; host=apollo-$ISP
  53. X        elif test -f /bin/pyr && /bin/pyr
  54. X        then PYR=yes; host=pyr
  55. X        elif test -d /NextApps
  56. X        then host=next
  57. X                      if test -d /NextDeveloper/Headers/bsd
  58. X                      then NEXT=3.x; headerdir=${headerdir}/bsd
  59. X                      else NEXT=2.x
  60. X                      fi
  61. X        elif test -f /etc/comply
  62. X        then SUN=yes; host=sun3
  63. X        elif test -f /bin/hinv
  64. X        then SGI=yep; host=iris4d
  65. X        elif grep ULTRIX ${headerdir}/stdio.h >/dev/null 2>&1
  66. X        then ULTRIX=yep; host=vax
  67. X        elif grep 'Property of IBM' ${headerdir}/stdio.h >/dev/null 2>&1
  68. X        then AIX=yep
  69. X        else host=`(tcsh -fc 'echo $HOSTTYPE' || arch || machine || mach || echo $machine) 2>/dev/null`
  70. X        fi;;
  71. X    esac;;
  72. XHP-UX)    HPUX=`uname -r 2>/dev/null || echo yep`; machid=`uname -m`
  73. X    case "$machid" in
  74. X    "") host=hp9000;;
  75. X    9000/[0-9][0-9][0-9])
  76. X        host=`echo "hp$machid" | sed 's,/\(.\)..,s\100,'`;;
  77. X    *) host=hp-unknown;;
  78. X    esac;;
  79. XAIX*)    AIX=yep; machid=`uname -m`
  80. X    case "$machid" in
  81. X    00*) host=rs6000;;
  82. X    10*) host=ibm032;;
  83. X    20*) host=ibm032;;
  84. X    esac;;
  85. XA/UX)    MAC=yep; host=macII;;
  86. Xdgux)    DGUX=yep; machid=`uname -m`
  87. X    case "$machid" in
  88. X    AViiON) host=aviion;;
  89. X    esac;;
  90. XSunOS)    machid=`uname -m`
  91. X    SUN=yep; case "$machid" in
  92. X    sun3*) host=sun3;;
  93. X    sun4*) host=sun4;;
  94. X    *) host=$machid;;
  95. X    esac;;
  96. XULTRIX)    machid=`uname -m`
  97. X    ULTRIX=yep; case "$machid" in
  98. X    VAX) host=vax;;
  99. X    *) host=$machid;;
  100. X    esac;;
  101. XIRIX)    SGI=yep; host=iris4d;;
  102. XOSF1)    OSF=yep; host=alpha;;
  103. X*)    machid=`uname -m`
  104. X    case "$machid" in
  105. X    mips|IP6|IP7) MIPS=yep; host=mips;;
  106. X    *) host=`(tcsh -fc 'echo $HOSTTYPE' || arch || machine || mach || echo $machine || echo $machid) 2>/dev/null`
  107. X    esac;;
  108. Xesac
  109. Xif test "$host"
  110. Xthen echo "...looks like a $host"
  111. X    case $host in
  112. X    mips) if test -d /usr/include/bsd43; then headerdir=/usr/include/bsd43; fi;;
  113. X    esac
  114. Xelse echo "...no luck on that score.  Continuing..."
  115. Xfi
  116. Xecho '
  117. XBuilding config.h...
  118. X'
  119. Xexec >config.h
  120. Xcat <<'foo'
  121. X/* this file is created automatically by buildzsh */
  122. X
  123. X/* define this if you are sysvish */
  124. Xfoo
  125. Xif test -f ${headerdir}/sys/resource.h -a ! -f ${headerdir}/sys/elf.h
  126. Xthen echo '/* #define SYSV */'; echo 'looks like a BSDish system...' >&2
  127. Xelse echo '#define SYSV'; echo 'looks like a SYSVish system...' >&2
  128. X PATH=/usr/bin:$PATH; export PATH; echo 'forcing /usr/bin early in PATH' >&2
  129. X if test -f ${headerdir}/sys/elf.h
  130. X then echo '#define SYSVR4'; echo 'looks like a SYSVR4 system...' >&2
  131. X fi
  132. Xfi
  133. Xecho
  134. Xif test "$ULTRIX"
  135. Xthen echo '#define ULTRIX
  136. X/* ULTRIX termios is weird... */
  137. X/* #define TERMIOS */'; echo 'using sgttyb...' >&2
  138. Xelse
  139. Xif test -f ${headerdir}/termios.h -a -z "$HPUX" -a -z "$APOLLO" -a -z "$BBN"
  140. Xthen echo '#define TERMIOS
  141. X/* #define TTY_NEEDS_DRAINING */
  142. X/* #define CLOBBERS_TYPEAHEAD */'
  143. Xecho 'using termios...' >&2
  144. Xelse
  145. Xif grep sgttyb ${headerdir}/sys/ioctl.h >/dev/null 2>&1
  146. Xthen echo '/* #define TERMIO */'
  147. Xelse echo '#define TERMIO'
  148. Xecho 'using termio...' >&2
  149. Xfi
  150. Xecho '#define TTY_NEEDS_DRAINING
  151. X#define CLOBBERS_TYPEAHEAD'
  152. Xecho 'using sgttyb...' >&2
  153. Xfi
  154. Xfi
  155. Xecho
  156. Xif test -f ${headerdir}/dirent.h -a -z "$ULTRIX"
  157. Xthen echo '#define HAS_DIRENT'; echo 'using <dirent.h>...' >&2
  158. Xelse echo '/*#define HAS_DIRENT*/'; echo 'not using <dirent.h>...' >&2
  159. Xfi
  160. Xecho
  161. Xif test -f ${headerdir}/unistd.h
  162. Xthen echo '#define HAS_UNISTD'; echo 'using <unistd.h>...' >&2
  163. Xelse echo '/*#define HAS_UNISTD*/'; echo 'not using <unistd.h>...' >&2
  164. Xfi
  165. Xecho
  166. Xif test -f ${headerdir}/stdlib.h &&
  167. X    grep alloc ${headerdir}/stdlib.h >/dev/null 2>&1
  168. Xthen echo '#define HAS_STDLIB'; echo 'using <stdlib.h>...' >&2
  169. Xelif test -n "${NEXT}"
  170. Xthen echo '#define HAS_STDLIB'; echo 'using <stdlib.h> (where NeXT hid it) ...' >&2
  171. Xelse echo '/*#define HAS_STDLIB*/'; echo 'not using <stdlib.h>...' >&2
  172. Xfi
  173. Xecho
  174. Xif test -f ${headerdir}/string.h
  175. Xthen echo '#define HAS_STRING'; echo 'using <string.h>...' >&2
  176. Xelse echo '/*#define HAS_STRING*/'; echo 'using <strings.h>...' >&2
  177. Xif test "${NEXT}" != "3.x"
  178. Xthen echo '#define strchr    index
  179. X#define strrchr    rindex'
  180. Xfi
  181. Xfi
  182. Xecho
  183. Xif test -f ${headerdir}/memory.h
  184. Xthen echo '#define HAS_MEMORY'; echo 'using <memory.h>...' >&2
  185. Xelse echo '/*#define HAS_MEMORY*/'; echo 'not using <memory.h>...' >&2
  186. Xif grep memset ${headerdir}/string.h >/dev/null 2>&1
  187. Xthen echo 'using memcpy,memset,memcmp from <string.h>...' >&2
  188. Xelse echo 'redefining memcpy,memset,memcmp...' >&2
  189. Xecho '#define memcpy(dst, src, n)    bcopy(src, dst, n)
  190. X#define memset(dst, ch, n)    do {\
  191. X    char *__DST__ = (char *)(dst);\
  192. X    int __N__ = (int)(n), __CH__ = (int)(ch);\
  193. X    while (__N__--) { __DST__[__N__] = __CH__; } } while(0)
  194. X#define memcmp(s1, s2, n)    bcmp(s1, s2, n)'
  195. Xfi
  196. Xfi
  197. Xecho
  198. Xif test -f ${headerdir}/locale.h
  199. Xthen echo '#define HAS_LOCALE'; echo 'using <locale.h>...' >&2
  200. Xelse echo '/*#define HAS_LOCALE*/'; echo 'not using <locale.h>...' >&2
  201. Xfi
  202. Xecho
  203. Xif test -f ${headerdir}/utmpx.h
  204. Xthen echo '#define HAS_UTMPX'; echo 'using <utmpx.h>...' >&2
  205. Xutmphdr=${headerdir}/utmpx.h
  206. Xelse echo '/*#define HAS_UTMPX*/'; echo 'not using <utmpx.h>...' >&2
  207. Xutmphdr=${headerdir}/utmp.h
  208. Xfi
  209. Xecho
  210. Xif grep ut_host $utmphdr >/dev/null 2>&1 && test "$host" != mips
  211. Xthen echo '#define UTMP_HOST'; echo 'host field in utmp...' >&2
  212. Xelse echo '/* #define UTMP_HOST */'; echo 'no host field in utmp...' >&2
  213. Xfi
  214. Xecho
  215. Xif test -f ${headerdir}/time.h && 
  216. X    grep timeval ${headerdir}/time.h >/dev/null 2>&1
  217. Xthen echo '#define HAS_TIME'; echo 'using <time.h>...' >&2
  218. Xelse echo '/*#define HAS_TIME*/'; echo 'using <sys/time.h>...' >&2
  219. Xfi
  220. Xecho
  221. Xif test -f ${headerdir}/wait.h
  222. Xthen echo '#define HAS_WAIT'; echo 'using <wait.h>...' >&2
  223. Xelse echo '/*#define HAS_WAIT*/'; echo 'using <sys/wait.h>...' >&2
  224. Xfi
  225. Xecho
  226. Xecho '/* define this if you have WAITPID */'
  227. Xif man 2 wait 2>/dev/null | sed 's/_.//g' | grep waitpid >/dev/null || \
  228. X grep 'waitpid.*(' ${headerdir}/wait.h >/dev/null 2>&1 || \
  229. X grep 'waitpid.*(' ${headerdir}/sys/wait.h >/dev/null 2>&1
  230. Xthen echo '#define WAITPID'; echo 'using waitpid()...' >&2
  231. Xelse echo '/* #define WAITPID */'; echo 'not using waitpid()...' >&2
  232. Xfi
  233. Xecho
  234. Xecho '/* define this if you have SELECT */'
  235. Xif grep FD_SET ${headerdir}/sys/types.h >/dev/null 2>&1 ||
  236. X    test -f ${headerdir}/sys/select.h
  237. Xthen echo '#define HAS_SELECT'; echo 'using select()...' >&2
  238. Xelse echo '/* #define HAS_SELECT */'; echo 'not using select()...' >&2
  239. Xfi
  240. Xecho
  241. Xecho '/* define this if you have <sys/select.h> */'
  242. Xif test -f ${headerdir}/sys/select.h
  243. Xthen echo '#define HAS_SYS_SELECT'
  244. Xelse echo '/* #define HAS_SYS_SELECT */'
  245. Xfi
  246. Xecho "
  247. X/* we can't just test for S_IFIFO or check to see if the mknod worked,
  248. X   because the NeXTs sold by a vendor which will remain nameless will
  249. X   happily create the FIFO for you, and then panic when you try to do
  250. X    something weird with them, because they aren't supported by the OS. */
  251. X"
  252. Xif test -n "$NEXT" -a "$NEXT" = "2.x"
  253. Xthen echo '#define NO_FIFOS'; echo 'no FIFOs...' >&2
  254. Xelse echo '/* #define NO_FIFOS */'; echo 'using FIFOs...' >&2
  255. Xfi
  256. Xecho
  257. Xecho '/* define this if you have strftime() */'
  258. Xif test "$host" != mips &&
  259. X    man 3 strftime 2>/dev/null | grep return >/dev/null
  260. Xthen echo '#define HAS_STRFTIME'; echo 'using strftime()...' >&2
  261. Xelse echo '/* #define HAS_STRFTIME */'; echo 'not using strftime()...' >&2
  262. Xfi
  263. Xecho
  264. Xif test "$host" != mips &&
  265. X    man tcsetpgrp 2>/dev/null | grep process >/dev/null || \
  266. X    grep tcsetpgrp ${headerdir}/unistd.h >/dev/null 2>&1
  267. Xthen echo '#define HAS_TCSETPGRP'; echo 'using tcsetpgrp()...' >&2
  268. Xelse echo '/* #define HAS_TCSETPGRP */'; echo 'not using tcsetpgrp()...' >&2
  269. Xfi
  270. Xecho
  271. Xif grep tcgetattr ${headerdir}/termios.h >/dev/null 2>&1 ||
  272. X    grep tcgetattr ${headerdir}/sys/termios.h >/dev/null 2>&1 ||
  273. X    grep tcgetattr ${headerdir}/sys/termio.h >/dev/null 2>&1
  274. Xthen echo '#define HAS_TCCRAP'; echo 'using tcgetattr() and friends...' >&2
  275. Xelse echo '/* #define HAS_TCCRAP */'; echo 'not using tcgetattr()...' >&2
  276. Xfi
  277. Xecho
  278. Xif test "$SGI" -o "$MIPS"
  279. Xthen echo '/* SGI setpgid() is weird...  setpgrp() is better anyway */
  280. X/* #define HAS_SETPGID */'; echo 'using setpgrp()...' >&2
  281. Xelif man setpgid 2>/dev/null | grep process >/dev/null
  282. Xthen echo '#define HAS_SETPGID'; echo 'using setpgid()...' >&2
  283. Xelse echo '/* #define HAS_SETPGID */'; echo 'using setpgrp()...' >&2
  284. Xfi
  285. Xecho
  286. Xif test -z "$HPUX" -a -z "$PYR" -a -z "$MIPS" &&
  287. X    { man sigrelse 2>/dev/null | grep signal >/dev/null ||
  288. X    grep SIGRELSE ${headerdir}/sys/signal.h > /dev/null 2>&1 ; }
  289. Xthen echo '#define HAS_SIGRELSE'; echo 'using sigrelse()...' >&2
  290. Xelse echo '/* #define HAS_SIGRELSE */'; echo 'using sigblock()...' >&2
  291. Xfi
  292. Xecho
  293. Xecho '/* define this if you have RFS */'
  294. Xif test -d /../.CONTROL
  295. Xthen echo '#define HAS_RFS'; echo 'you seem to have RFS...' >&2
  296. Xelse echo '/* #define HAS_RFS */'; echo 'no RFS, it seems...' >&2
  297. Xfi
  298. Xecho
  299. Xecho '/* define this if you have a working getrusage and wait3 */'
  300. Xif test "$HPUX"
  301. Xthen echo '/* #define HAS_RUSAGE */'; echo 'no getrusage...' >&2
  302. Xelif test -f ${headerdir}/sys/resource.h
  303. Xthen echo '#define HAS_RUSAGE'; echo 'has getrusage...' >&2
  304. Xelse echo '/* #define HAS_RUSAGE */'; echo 'no getrusage...' >&2
  305. Xfi
  306. Xif test "$host" = hp9000s700
  307. Xthen echo '/* kludge RLIM code for HPUX s700 - These limits are all readable,and
  308. X * some like coredumpsize are settable by users
  309. X */
  310. X#define RLIMIT_CPU      0               /* cpu time in milliseconds */
  311. X#define RLIMIT_FSIZE    1               /* maximum file size */
  312. X#define RLIMIT_DATA     2               /* data size */
  313. X#define RLIMIT_STACK    3               /* stack size */
  314. X#define RLIMIT_CORE     4               /* core file size */
  315. X#define RLIMIT_RSS      5               /* resident set size */
  316. X
  317. X#define RLIM_INFINITY   0x7fffffff
  318. X'
  319. Xfi
  320. Xecho '/* define this if you use NIS for your passwd map */'
  321. Xif test -f /usr/bin/ypcat && ypcat passwd.byname >/dev/null 2>&1
  322. Xthen echo '#define HAS_NIS_PASSWD'; echo 'using NIS passwd code...' >&2
  323. Xelse echo '/* #define HAS_NIS_PASSWD */'; echo 'no NIS passwd map, it seems...' >&2
  324. Xfi
  325. Xecho '
  326. X/* define this if your signal handlers return void */'
  327. Xif egrep 'SIG_DFL|sighandler_t' ${headerdir}/signal.h ${headerdir}/sys/signal.h 2>/dev/null |
  328. X    grep void >/dev/null
  329. Xthen echo '#define SIGVOID'; echo 'signal handlers return void...' >&2
  330. Xelse echo '/* #define SIGVOID */'; echo 'signal handlers return int...' >&2
  331. Xfi
  332. Xcat <<'foo'
  333. X#ifdef sgi
  334. X#undef SIGVOID
  335. X#endif
  336. Xfoo
  337. Xecho
  338. Xecho '/* define this if signal handlers need to be reset each time */'
  339. Xif grep SIGTSTP ${headerdir}/signal.h >/dev/null 2>&1 ||
  340. X    grep SIGTSTP ${headerdir}/sys/signal.h >/dev/null 2>&1
  341. Xthen echo '/* #define RESETHANDNEEDED */'
  342. Xecho 'signal handlers need no resetting...' >&2
  343. X if test -z "$HPUX" -a -z "$MIPS" &&
  344. X    man 2 sigset 2>/dev/null | grep handler >/dev/null
  345. X then echo '#define signal sigset'; echo '.. when installed with sigset()' >&2
  346. X fi
  347. Xelse echo '#define RESETHANDNEEDED'
  348. Xecho 'signal handlers need to be reset...' >&2
  349. Xfi
  350. Xecho
  351. Xcat <<'foo'
  352. X#ifdef SIGVOID
  353. X#define HANDTYPE void
  354. X#else
  355. X#define HANDTYPE int
  356. X#define INTHANDTYPE
  357. X#endif
  358. X
  359. X/* a string corresponding to the host type */
  360. Xfoo
  361. Xecho '#define HOSTTYPE "' | tr -d '\012'
  362. Xif test -z "$host"
  363. Xthen
  364. X    echo 1>&2 '
  365. X
  366. XI cannot figure out what sort of host this is.  Please enter one
  367. Xshort alphanumeric string describing this host.  (This will be used
  368. Xto set the $HOSTTYPE variable, so '"you don't have to be very
  369. Xaccurate if you're not in a multivendor environment.)
  370. X"
  371. X     echo "? " | tr -d '\012' 1>&2
  372. X     read host
  373. X     echo ' ' 1>&2
  374. Xfi
  375. Xecho $host'"'
  376. Xecho "using host type $host..." >&2
  377. Xecho
  378. Xecho '/* the default editor for the fc builtin */'
  379. Xecho '#define DEFFCEDIT "vi"'
  380. Xecho
  381. Xif egrep 'UTMP_FILE|_PATH_UTMP' ${headerdir}/utmp.h >/dev/null 2>&1
  382. Xthen :
  383. Xelse 
  384. Xecho '/* the path of wtmp */'
  385. Xecho '#define WTMP_FILE "' | tr -d '\012'
  386. Xif test -f /etc/wtmp
  387. Xthen echo /etc/wtmp
  388. Xelif test -f /usr/etc/wtmp
  389. Xthen echo /usr/etc/wtmp
  390. Xelif test -f /var/adm/wtmp
  391. Xthen echo /var/adm/wtmp
  392. Xelif test -f /usr/adm/wtmp
  393. Xthen echo /usr/adm/wtmp
  394. Xelse echo /dev/null
  395. Xfi | tr -d '\012'
  396. Xecho '"
  397. X
  398. X/* the path of utmp */
  399. X#define UTMP_FILE "/etc/utmp"
  400. X'
  401. Xfi
  402. Xcat <<'foo'
  403. X/* default prefix for temporary files */
  404. X#define DEFTMPPREFIX "/tmp/zsh"
  405. X
  406. X/* define if you prefer "suspended" to "stopped" */
  407. X#define USE_SUSPENDED
  408. X
  409. X/* the file to source absolutely first whenever zsh is run; if undefined,
  410. X      don't source anything */
  411. X#define GLOBALZSHENV "/etc/zshenv"
  412. X
  413. X/* the file to source whenever zsh is run; if undefined, don't source
  414. X    anything */
  415. X#define GLOBALZSHRC "/etc/zshrc"
  416. X
  417. X/* the file to source whenever zsh is run as a login shell; if
  418. X    undefined, don't source anything */
  419. X#define GLOBALZLOGIN "/etc/zlogin"
  420. X
  421. X/* the file to source whenever zsh is run as a login shell, before
  422. X    zshrc is read; if undefined, don't source anything */
  423. X#define GLOBALZPROFILE "/etc/zprofile"
  424. X
  425. X/* the default HISTSIZE */
  426. X#define DEFAULT_HISTSIZE 30
  427. X
  428. X#define _BSD_SIGNALS   /* this could be an iris, you never know */
  429. X#define _BSD           /* this could be HP-UX, you never know */
  430. X#define _BSD_INCLUDES  /* this could be AIX, you never know */
  431. X#define _BBN_POSIX_SUPPORT    /* this could be nX, you never know */
  432. X
  433. X/* if your compiler doesn't like void *, change this to char *
  434. X    and ignore all the warnings.
  435. X*/
  436. X
  437. Xtypedef void *vptr;
  438. X
  439. X#define JOB_CONTROL
  440. Xfoo
  441. Xexec 1>&2
  442. Xecho
  443. Xecho 'Building signals.h...' | tr -d '\012'
  444. Xecho `csh -fc 'kill -l'` | tr ' ' '\012' >signals.h
  445. Xlct=`wc -l < signals.h`
  446. Xcp signals.h signams.h
  447. X(
  448. Xecho '/* this file is created automatically by buildzsh */
  449. X/* if all this is wrong, blame csh ;-) */
  450. X
  451. X#define SIGCOUNT '"$lct"'
  452. X
  453. X#ifdef GLOBALS
  454. X
  455. Xchar *sigmsg[SIGCOUNT+2] = {
  456. X    "done",'
  457. Xsed -e 's/^/SIG/' -e '/SIGHUP/s//hangup/
  458. X/SIGINT/s//interrupt/
  459. X/SIGQUIT/s//quit/
  460. X/SIGILL/s//illegal instruction/
  461. X/SIGTRAP/s//trace trap/
  462. X/SIGIOT/s//IOT instruction/
  463. X/SIGABRT/s//abort/
  464. X/SIGEMT/s//EMT instruction/
  465. X/SIGFPE/s//floating point exception/
  466. X/SIGKILL/s//killed/
  467. X/SIGBUS/s//bus error/
  468. X/SIGSEGV/s//segmentation fault/
  469. X/SIGSYS/s//bad system call/
  470. X/SIGPIPE/s//broken pipe/
  471. X/SIGTERM/s//terminated/
  472. X/SIGPWR/s//power fail/
  473. X/SIGVTALRM/s//virtual time alarm/
  474. X/SIGCONT/s//continued/
  475. X/SIGXCPU/s//cpu limit exceeded/
  476. X/SIGXFSZ/s//filesize limit exceeded/' -e 's/.*/    "&",/' signals.h
  477. Xecho '    NULL
  478. X};
  479. X
  480. Xchar *sigs[SIGCOUNT+4] = {
  481. X    "EXIT",' ) >sigtmp.h
  482. Xmv sigtmp.h signals.h
  483. Xif grep SIGSTOP signals.h >/dev/null
  484. Xthen ed signals.h <<'foo' >/dev/null 2>&1
  485. X/SIGSTOP/c
  486. X#ifdef USE_SUSPENDED
  487. X    "suspended (signal)",
  488. X#else
  489. X    "stopped (signal)",
  490. X#endif
  491. X.
  492. X/SIGTSTP/c
  493. X#ifdef USE_SUSPENDED
  494. X    "suspended",
  495. X#else
  496. X    "stopped",
  497. X#endif
  498. X.
  499. X/SIGTTIN/c
  500. X#ifdef USE_SUSPENDED
  501. X    "suspended (tty input)",
  502. X#else
  503. X    "stopped (tty input)",
  504. X#endif
  505. X.
  506. X/SIGTTOU/c
  507. X#ifdef USE_SUSPENDED
  508. X    "suspended (tty output)",
  509. X#else
  510. X    "stopped (tty output)",
  511. X#endif
  512. X.
  513. Xw
  514. Xq
  515. Xfoo
  516. Xfi
  517. X(sed 's/.*/    "&",/' signams.h
  518. Xecho '    "ERR",
  519. X    "DEBUG",
  520. X    NULL
  521. X};
  522. X
  523. X#else
  524. X
  525. Xextern char *sigs[SIGCOUNT+4],*sigmsg[SIGCOUNT+2];
  526. X
  527. X#endif') >>signals.h
  528. Xrm signams.h
  529. Xecho done
  530. Xecho 'Building Makefile...' | tr -d '\012'
  531. Xexec >Makefile
  532. Xcat <<'foo'
  533. X#! /bin/make -f
  534. X# Makefile for zsh
  535. X# generated by buildzsh
  536. X
  537. XAUX=buildzsh
  538. X
  539. XSRC=builtin.c cond.c exec.c glob.c hist.c init.c jobs.c lex.c loop.c \
  540. Xmath.c mem.c params.c parse.c subst.c table.c text.c utils.c watch.c \
  541. Xzle_bindings.c zle_hist.c zle_main.c zle_misc.c zle_move.c zle_refresh.c \
  542. Xzle_tricky.c zle_utils.c zle_vi.c zle_word.c
  543. X
  544. XHEADER=funcs.h zle.h zsh.h ztype.h
  545. X
  546. XPROTO=builtin.pro cond.pro exec.pro glob.pro hist.pro init.pro jobs.pro \
  547. Xlex.pro loop.pro math.pro mem.pro params.pro parse.pro subst.pro table.pro \
  548. Xtext.pro utils.pro watch.pro zle_bindings.pro zle_hist.pro zle_main.pro \
  549. Xzle_misc.pro zle_move.pro zle_refresh.pro zle_tricky.pro zle_utils.pro \
  550. Xzle_vi.pro zle_word.pro
  551. X
  552. XOBJS=builtin.o cond.o exec.o glob.o hist.o init.o jobs.o lex.o loop.o \
  553. Xmath.o mem.o params.o parse.o subst.o table.o text.o utils.o watch.o \
  554. Xzle_bindings.o zle_hist.o zle_main.o zle_misc.o zle_move.o zle_refresh.o \
  555. Xzle_tricky.o zle_utils.o zle_vi.o zle_word.o
  556. X
  557. XBINDIR=/usr/local/bin
  558. XMANDIR=/usr/local/man/man1
  559. X
  560. X# Debugging flags
  561. XDFLAGS = # -DQDEBUG
  562. X
  563. X# For gcc 2.3.3
  564. X#CC=gcc -fpcc-struct-return
  565. X#CFLAGS= -O2 -g -Wall -Wno-implicit -Wno-parentheses -Wno-comment $(DFLAGS)
  566. X
  567. Xfoo
  568. Xif test "$MIPS"
  569. Xthen echo 'CC=cc -systype bsd43'
  570. Xelse echo 'CC=cc'
  571. Xfi
  572. Xif test "$APOLLO"
  573. Xthen echo 'CFLAGS= -O -A nansi'
  574. Xelif test "$HPUX"
  575. Xthen export HPUX; echo "CFLAGS= -O `[ "$HPUX" = "7.03" ] && echo -Wc,-Ns5000`"
  576. Xelif test "$ULTRIX"
  577. Xthen echo 'CFLAGS= -O -Olimit 600'
  578. Xelif test "$MIPS"
  579. Xthen echo 'CFLAGS= -O -Olimit 1000 -Wf,-XNd5000 -Wf,-XNl4096'
  580. Xelif test "$OSF"
  581. Xthen echo 'CFLAGS= -O -I/usr/sys/include  -I/usr/sys/BINARY -D__rpc_types_h -Dbool_t=int -Denum_t=int'
  582. Xelif test -f ${headerdir}/ndir.h -a ! -f /usr/lib/libBSD.a
  583. Xthen echo 'CFLAGS= -O -Aa'
  584. Xelif strings /usr/bin/cc 2>/dev/null | grep cckr >/dev/null 2>&1
  585. Xthen echo 'CFLAGS= -O -cckr'
  586. Xelif cc -v 2>&1 | egrep '^gcc version (1\.9|[2-9])' >/dev/null 2>&1
  587. Xthen echo 'CFLAGS= -O2 -pipe'
  588. Xelse echo 'CFLAGS= -O'
  589. Xfi
  590. Xif test "$SGI"
  591. Xthen
  592. Xif grep '^\+' /etc/passwd >/dev/null 2>&1
  593. Xthen echo 'LIBS= -lcurses -lmalloc -lbsd -lsun'
  594. Xelse echo 'LIBS= -lcurses -lmalloc -lbsd'
  595. Xfi
  596. Xelif test "$BBN"
  597. Xthen echo 'LIBS= -ltermcap -lposix'
  598. Xelif test "$HPUX"
  599. Xthen echo 'LIBS= -ltermcap -lBSD'
  600. Xelif test -f /usr/lib/libcposix.a
  601. Xthen echo 'LIBS= -lcposix -ltermcap'
  602. Xelif test -f /usr/lib/libBSD.a
  603. Xthen echo 'LIBS= -ltermcap -lBSD'
  604. Xelif test -f /usr/lib/libtermcap.a -o -f /usr/ucblib/libtermcap.a
  605. Xthen
  606. X    if test "$AIX"
  607. X    then echo 'LIBS= -lcurses'
  608. X    else echo 'LIBS= -ltermcap'
  609. X    fi
  610. Xelse echo 'LIBS= -lcurses'
  611. Xfi
  612. Xcat <<'foo'
  613. X
  614. XZSHPATH=zsh
  615. X
  616. X.SUFFIXES: .c .o .pro
  617. X
  618. X.c.o:
  619. X    $(CC) $(CFLAGS) $(DFLAGS) -c $<
  620. X
  621. X.c.pro:
  622. X    sed -n '/\/\*\*\/$$/{N;s/^\([^(]*\).*\/\*\*\/.\(.*\)/\1 DCLPROTO((\2))/p;}' $< | sed -e 's/;/,/g' -e 's/,))$$/));/' -e 's/(({))$$/((void));/' >$@
  623. X
  624. Xall: $(PROTO) $(ZSHPATH)
  625. X
  626. X$(ZSHPATH): $(OBJS)
  627. X    $(CC) -o $(ZSHPATH) $(OBJS) $(LIBS) $(LFLAGS)
  628. X    
  629. Xtags: /tmp
  630. X    ctags *.[cy]
  631. X
  632. X# I hate this next line
  633. X$(OBJS): config.h zsh.h zle.h signals.h ztype.h funcs.h
  634. X
  635. Xparams.o: version.h
  636. X
  637. Xclean:
  638. X    rm -f *.o *.pro zsh core 
  639. X
  640. Xcleanall:
  641. X    rm -f *.o *.pro zsh core Makefile signals.h config.h
  642. X
  643. Xinstall: zsh
  644. X    install -s -m 755 zsh $(BINDIR)
  645. X    install -m 444 ../man/man1/zsh.1 $(MANDIR)
  646. Xfoo
  647. Xexec 1>&2
  648. Xecho done
  649. Xcat <<'foo'
  650. Xdone
  651. X
  652. XYou may want to look at the files I just created (config.h, Makefile,
  653. Xand signals.h) to make sure they are correct.  Or you may just want
  654. Xto go ahead and try running make now to see what happens.
  655. X
  656. Xfoo
  657. Xecho 'Shall I execute make now?' | tr -d '\012' 
  658. Xread reply
  659. Xecho
  660. Xcase "$reply" in
  661. X[yY]*) exec make ;;
  662. Xesac
  663. END_OF_FILE
  664.   if test 18846 -ne `wc -c <'src/buildzsh'`; then
  665.     echo shar: \"'src/buildzsh'\" unpacked with wrong size!
  666.   fi
  667.   chmod +x 'src/buildzsh'
  668.   # end of 'src/buildzsh'
  669. fi
  670. if test -f 'src/init.c' -a "${1}" != "-c" ; then 
  671.   echo shar: Will not clobber existing file \"'src/init.c'\"
  672. else
  673.   echo shar: Extracting \"'src/init.c'\" \(14274 characters\)
  674.   sed "s/^X//" >'src/init.c' <<'END_OF_FILE'
  675. X/*
  676. X *
  677. X * init.c - main loop and initialization routines
  678. X *
  679. X * This file is part of zsh, the Z shell.
  680. X *
  681. X * This software is Copyright 1992 by Paul Falstad
  682. X *
  683. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  684. X * use this software as long as: there is no monetary profit gained
  685. X * specifically from the use or reproduction of this software, it is not
  686. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  687. X * included prominently in any copy made. 
  688. X *
  689. X * The author make no claims as to the fitness or correctness of this software
  690. X * for any use whatsoever, and it is provided as is. Any use of this software
  691. X * is at the user's own risk. 
  692. X *
  693. X */
  694. X
  695. X#define GLOBALS
  696. X#include "zsh.h"
  697. X#include <pwd.h>
  698. X
  699. Xstatic int noexitct = 0;
  700. X
  701. Xvoid main(argc,argv,envp) /**/
  702. Xint argc; char **argv; char **envp;
  703. X{
  704. Xchar *zshname;
  705. X
  706. X#ifdef LC_ALL
  707. X    setlocale(LC_ALL, "");
  708. X#endif
  709. X    environ = envp;
  710. X    meminit();
  711. X    if (!(zshname = strrchr(argv[0], '/')))
  712. X        zshname = argv[0];
  713. X    else
  714. X        zshname++;
  715. X    setflags(zshname);
  716. X    parseargs(argv);
  717. X    setmoreflags();
  718. X    setupvals();
  719. X    initialize();
  720. X    heapalloc();
  721. X    runscripts(zshname);
  722. X    for(;;)
  723. X        {
  724. X        do
  725. X            loop(1);
  726. X        while (tok != ENDINPUT);
  727. X        if (!(isset(IGNOREEOF) && interact))
  728. X            {
  729. X#if 0
  730. X            if (interact)
  731. X                fputs(islogin ? "logout\n" : "exit\n",stderr);
  732. X#endif
  733. X            zexit(lastval);
  734. X            continue;
  735. X            }
  736. X        noexitct++;
  737. X        if (noexitct >= 10)
  738. X            {
  739. X            stopmsg = 1;
  740. X            zexit(lastval);
  741. X            }
  742. X        zerrnam("zsh",(!islogin) ? "use 'exit' to exit."
  743. X            : "use 'logout' to logout.",NULL,0);
  744. X        }
  745. X}
  746. X
  747. X/* keep executing lists until EOF found */
  748. X
  749. Xvoid loop(toplevel) /**/
  750. Xint toplevel;
  751. X{
  752. XList list;
  753. XHeap h = (Heap) peekfirst(heaplist);
  754. X
  755. X    pushheap();
  756. X    for(;;)
  757. X        {
  758. X        freeheap();
  759. X        if (interact && isset(SHINSTDIN))
  760. X            preprompt();
  761. X        hbegin();        /* init history mech */
  762. X        intr();            /* interrupts on */
  763. X        ainit();            /* init alias mech */
  764. X        lexinit();
  765. X        errflag = 0;
  766. X        if (!(list = parse_event()))
  767. X            {                /* if we couldn't parse a list */
  768. X            hend();
  769. X            if (tok == ENDINPUT && !errflag)
  770. X                break;
  771. X            continue;
  772. X            }
  773. X        if (hend())
  774. X            {
  775. X            if (stopmsg)        /* unset 'you have stopped jobs' flag */
  776. X                stopmsg--;
  777. X            execlist(list);
  778. X            if (toplevel)
  779. X                noexitct = 0;
  780. X            }
  781. X        if (ferror(stderr))
  782. X            {
  783. X            zerr("write error",NULL,0);
  784. X            clearerr(stderr);
  785. X            }
  786. X        if (subsh)                /* how'd we get this far in a subshell? */
  787. X            exit(lastval);
  788. X        if ((!interact && errflag) || retflag)
  789. X            break;
  790. X        if (isset('t') || (lastval && isset(ERREXIT)))
  791. X            {
  792. X            if (sigtrapped[SIGEXIT])
  793. X                dotrap(SIGEXIT);
  794. X            exit(lastval);
  795. X            }
  796. X        }
  797. X    while ((Heap) peekfirst(heaplist) != h)
  798. X        popheap();
  799. X}
  800. X
  801. Xvoid setflags(zshname) /**/
  802. Xconst char *zshname;
  803. X{
  804. Xint c;
  805. X
  806. X    for (c = 0; c != 32; c++)        opts[c] = OPT_UNSET;
  807. X    for (c = 32; c != 128; c++)    opts[c] = OPT_INVALID;
  808. X    for (c = 'a'; c <= 'z'; c++)    opts[c] = opts[c-'a'+'A'] = OPT_UNSET;
  809. X    for (c = '0'; c <= '9'; c++)    opts[c] = OPT_UNSET;
  810. X    opts['A'] = OPT_INVALID;
  811. X    opts['i'] = (isatty(0)) ? OPT_SET : OPT_UNSET;
  812. X    opts[BGNICE] = opts[NOTIFY] = OPT_SET;
  813. X    opts[USEZLE] = (interact && SHTTY != -1) ? OPT_SET : OPT_UNSET;
  814. X    opts[HASHCMDS] = opts[HASHLISTALL] = opts[HASHDIRS] = OPT_SET;
  815. X
  816. X    /* KSH Mode:
  817. X        The following seven options cause zsh to behave more like KSH
  818. X        when invoked as "ksh".
  819. X        K - don't recognize csh-style history subst
  820. X        k - allow interactive comments
  821. X        I - don't perform brace expansion
  822. X        3 - don't print error for unmatched wildcards
  823. X        H - don't query 'rm *'
  824. X        y - split parameters using IFS
  825. X        KSHOPTIONPRINT - print options ksh-like
  826. X        wnp@rcvie.co.at, 1992-05-14
  827. X    */
  828. X
  829. X    if ( strcmp(zshname, "ksh") == 0 )
  830. X    {
  831. X        opts['K'] = opts['k'] = opts['I'] = opts['3'] = OPT_SET ;
  832. X        opts['H'] = opts['y'] = opts[KSHOPTIONPRINT] = OPT_SET ;
  833. X    }
  834. X}
  835. X
  836. Xstatic char *cmd;
  837. X
  838. Xvoid parseargs(argv) /**/
  839. Xchar **argv;
  840. X{
  841. Xchar **x;
  842. Xint bk = 0,action;
  843. XLklist paramlist;
  844. X
  845. X    hackzero = argzero = *argv;
  846. X    opts[LOGINSHELL] = (**(argv++) == '-') ? OPT_SET : OPT_UNSET;
  847. X    SHIN = 0;
  848. X    while (!bk && *argv && (**argv == '-' || **argv == '+'))
  849. X        {
  850. X        action = (**argv == '-') ? OPT_SET : OPT_UNSET;
  851. X        while (*++*argv) {
  852. X            if (opts[(int)**argv] == OPT_INVALID) {
  853. X                zerr("bad option: -%c",NULL,**argv);
  854. X                exit(1);
  855. X            }
  856. X            if (bk = **argv == 'b') break;
  857. X            if (**argv == 'c') { /* -c command */
  858. X                argv++;
  859. X                if (!*argv) {
  860. X                    zerr("string expected after -c",NULL,0);
  861. X                    exit(1);
  862. X                }
  863. X                cmd = *argv;
  864. X                opts[INTERACTIVE] = OPT_UNSET;
  865. X                opts['c'] = OPT_SET;
  866. X                break;
  867. X            } else if (**argv == 'o') {
  868. X                int c;
  869. X
  870. X                if (!*++*argv)
  871. X                    argv++;
  872. X                if (!*argv) {
  873. X                    zerr("string expected after -o",NULL,0);
  874. X                    exit(1);
  875. X                }
  876. X                c = optlookup(*argv);
  877. X                if (c == -1)
  878. X                    zerr("no such option: %s",*argv,0);
  879. X                else
  880. X                    opts[c] = action;
  881. X                break;
  882. X            } else opts[(int)**argv] = action;
  883. X        }
  884. X        argv++;
  885. X    }
  886. X    paramlist = newlist();
  887. X    if (*argv)
  888. X        {
  889. X        if (opts[SHINSTDIN] == OPT_UNSET)
  890. X            {
  891. X            SHIN = movefd(open(argzero = *argv,O_RDONLY));
  892. X            if (SHIN == -1)
  893. X                {
  894. X                zerr("can't open input file: %s",*argv,0);
  895. X                exit(1);
  896. X                }
  897. X            opts[INTERACTIVE] = OPT_UNSET;
  898. X            argv++;
  899. X            }
  900. X        while (*argv)
  901. X            addnode(paramlist,ztrdup(*argv++));
  902. X        }
  903. X    else
  904. X        opts[SHINSTDIN] = OPT_SET;
  905. X    pparams = x = zcalloc((countnodes(paramlist)+1)*sizeof(char *));
  906. X    while (*x++ = getnode(paramlist));
  907. X    free(paramlist);
  908. X    argzero = ztrdup(argzero);
  909. X}
  910. X
  911. Xvoid setmoreflags() /**/
  912. X{
  913. X#ifndef NOCLOSEFUNNYFDS
  914. Xint t0;
  915. X#endif
  916. Xlong ttpgrp;
  917. X
  918. X    /* stdout,stderr fully buffered */
  919. X#ifdef _IOFBF
  920. X    setvbuf(stdout,malloc(BUFSIZ),_IOFBF,BUFSIZ);
  921. X    setvbuf(stderr,malloc(BUFSIZ),_IOFBF,BUFSIZ);
  922. X#else
  923. X    setbuffer(stdout,malloc(BUFSIZ),BUFSIZ);
  924. X    setbuffer(stderr,malloc(BUFSIZ),BUFSIZ);
  925. X#endif
  926. X    subsh = 0;
  927. X#ifndef NOCLOSEFUNNYFDS
  928. X    /* this works around a bug in some versions of in.rshd */
  929. X    for (t0 = 3; t0 != 10; t0++)
  930. X        close(t0);
  931. X#endif
  932. X#ifdef JOB_CONTROL
  933. X    opts[MONITOR] = (interact) ? OPT_SET : OPT_UNSET;
  934. X    if (jobbing) {
  935. X        SHTTY = movefd((isatty(0)) ? dup(0) : open("/dev/tty",O_RDWR));
  936. X        if (SHTTY == -1)
  937. X            opts[MONITOR] = OPT_UNSET;
  938. X        else {
  939. X#ifdef TIOCSETD
  940. X#ifdef NTTYDISC
  941. X            int ldisc = NTTYDISC;
  942. X            ioctl(SHTTY, TIOCSETD, &ldisc);
  943. X#endif
  944. X#endif
  945. X            gettyinfo(&shttyinfo);    /* get tty state */
  946. X#ifdef sgi
  947. X            if (shttyinfo.tio.c_cc[VSWTCH] <= 0) /* hack for irises */
  948. X                shttyinfo.tio.c_cc[VSWTCH] = CSWTCH;
  949. X#endif
  950. X            savedttyinfo = shttyinfo;
  951. X        }
  952. X#ifdef sgi
  953. X        setpgrp(0,getpgrp(0));
  954. X#endif
  955. X        if ((mypgrp = getpgrp(0)) <= 0)
  956. X            opts[MONITOR] = OPT_UNSET;
  957. X        else while ((ttpgrp = gettygrp()) != -1 && ttpgrp != mypgrp) {
  958. X            sleep(1);
  959. X            mypgrp = getpgrp(0);
  960. X            if (mypgrp == gettygrp()) break;
  961. X            killpg(mypgrp,SIGTTIN);
  962. X            mypgrp = getpgrp(0);
  963. X        }
  964. X    } else
  965. X        SHTTY = -1;
  966. X#else
  967. X    opts[MONITOR] = OPT_UNSET;
  968. X    SHTTY = movefd((isatty(0)) ? dup(0) : open("/dev/tty",O_RDWR));
  969. X    if (SHTTY != -1) {
  970. X        gettyinfo(&shttyinfo);
  971. X        savedttyinfo = shttyinfo;
  972. X    }
  973. X#endif
  974. X}
  975. X
  976. Xstatic long
  977. Xget_baudrate(speedcode)
  978. Xint speedcode;
  979. X{
  980. X    switch(speedcode) {
  981. X        case B0:    return(0L);
  982. X        case B50:    return(50L);
  983. X        case B75:    return(75L);
  984. X        case B110:    return(110L);
  985. X        case B134:    return(134L);
  986. X        case B150:    return(150L);
  987. X        case B200:    return(200L);
  988. X        case B300:    return(300L);
  989. X        case B600:    return(600L);
  990. X#ifdef _B900
  991. X        case _B900:    return(900L);
  992. X#endif
  993. X        case B1200:    return(1200L);
  994. X        case B1800:    return(1800L);
  995. X        case B2400:    return(2400L);
  996. X#ifdef _B3600
  997. X        case _B3600:    return(3600L);
  998. X#endif
  999. X        case B4800:    return(4800L);
  1000. X#ifdef _B7200
  1001. X        case _B7200:    return(7200L);
  1002. X#endif
  1003. X        case B9600:    return(9600L);
  1004. X#ifdef B19200
  1005. X        case B19200:    return(19200L);
  1006. X#else
  1007. X#ifdef EXTA
  1008. X              case EXTA:      return(19200L);
  1009. X#endif
  1010. X#endif
  1011. X#ifdef B38400
  1012. X        case B38400:    return(38400L);
  1013. X#else
  1014. X#ifdef EXTB
  1015. X              case EXTB:      return(38400L);
  1016. X#endif
  1017. X#endif
  1018. X        default:    break;
  1019. X    }
  1020. X    return(0L);
  1021. X}
  1022. X
  1023. Xvoid setupvals() /**/
  1024. X{
  1025. Xstruct passwd *pswd;
  1026. Xchar *ptr,*s;
  1027. X
  1028. X    curhist = 0;
  1029. X    histsiz = DEFAULT_HISTSIZE;
  1030. X    lithistsiz = 5;
  1031. X    inithist();
  1032. X    mailcheck = logcheck = 60;
  1033. X    dirstacksize = -1;
  1034. X    listmax = 100;
  1035. X    reporttime = -1;
  1036. X    bangchar = '!';
  1037. X    hashchar = '#';
  1038. X    hatchar = '^';
  1039. X    termok = 0;
  1040. X    curjob = prevjob = coprocin = coprocout = -1;
  1041. X    shtimer = time(NULL);    /* init $SECONDS */
  1042. X    srand((unsigned int) shtimer);
  1043. X    /* build various hash tables; argument to newhtable is table size */
  1044. X    aliastab = newhtable(37);
  1045. X    addreswords();
  1046. X    paramtab = newhtable(151);
  1047. X    cmdnamtab = newhtable(37);
  1048. X    compctltab = newhtable(13);
  1049. X    initxbindtab();
  1050. X    nullcmd = ztrdup("cat");
  1051. X    readnullcmd = ztrdup("more");
  1052. X    prompt = ztrdup("%m%# ");
  1053. X    prompt2 = ztrdup("> ");
  1054. X    prompt3 = ztrdup("?# ");
  1055. X    prompt4 = ztrdup("+ ");
  1056. X    sprompt = ztrdup("zsh: correct `%R' to `%r' [nyae]? ");
  1057. X    term = ztrdup("");
  1058. X    ppid = getppid();
  1059. X#ifdef TIO
  1060. X#if defined(HAS_TCCRAP) && defined(TERMIOS)
  1061. X    baud = cfgetospeed(&shttyinfo.tio);
  1062. X    if (baud < 100) baud = get_baudrate(baud); /* aren't "standards" great?? */
  1063. X#else
  1064. X    baud = get_baudrate(shttyinfo.tio.c_cflag & CBAUD);
  1065. X#endif
  1066. X#else
  1067. X    baud = get_baudrate(shttyinfo.sgttyb.sg_ospeed);
  1068. X#endif
  1069. X#ifdef TIOCGWINSZ
  1070. X    if (!(columns = shttyinfo.winsize.ws_col))
  1071. X        columns = 80;
  1072. X    if (!(lines = shttyinfo.winsize.ws_row))
  1073. X        lines = 24;
  1074. X#else
  1075. X    columns = 80;
  1076. X    lines = 24;
  1077. X#endif
  1078. X    ifs = ztrdup(" \t\n");
  1079. X    if (pswd = getpwuid(getuid())) {
  1080. X        username = ztrdup(pswd->pw_name);
  1081. X        home = ztrdup(pswd->pw_dir);
  1082. X    } else {
  1083. X        username = ztrdup("");
  1084. X        home = ztrdup("/");
  1085. X    }
  1086. X    if (ptr = zgetenv("LOGNAME"))
  1087. X        logname = ztrdup(ptr);
  1088. X    else
  1089. X        logname = ztrdup(username);
  1090. X    timefmt = ztrdup(DEFTIMEFMT);
  1091. X    watchfmt = ztrdup(DEFWATCHFMT);
  1092. X    if (!(ttystrname = ztrdup(ttyname(SHTTY))))
  1093. X        ttystrname = ztrdup("");
  1094. X    wordchars = ztrdup(DEFWORDCHARS);
  1095. X    fceditparam = ztrdup(DEFFCEDIT);
  1096. X    tmpprefix = ztrdup(DEFTMPPREFIX);
  1097. X    postedit = ztrdup("");
  1098. X    if (ispwd(home)) pwd = ztrdup(home);
  1099. X    else if ((ptr = zgetenv("PWD")) && ispwd(ptr)) pwd = ztrdup(ptr);
  1100. X    else pwd = zgetwd();
  1101. X    oldpwd = ztrdup(pwd);
  1102. X    hostnam = zalloc(256);
  1103. X    underscore = ztrdup("");
  1104. X    gethostname(hostnam,256);
  1105. X    mypid = getpid();
  1106. X    cdpath = mkarray(NULL);
  1107. X    manpath = mkarray(NULL);
  1108. X    fignore = mkarray(NULL);
  1109. X    fpath = mkarray(NULL);
  1110. X    mailpath = mkarray(NULL);
  1111. X    watch = mkarray(NULL);
  1112. X    hosts = mkarray(NULL);
  1113. X    psvar = mkarray(NULL);
  1114. X    compctlsetup();
  1115. X    userdirs = (char **) zcalloc(sizeof(char *)*2);
  1116. X    usernames = (char **) zcalloc(sizeof(char *)*2);
  1117. X    userdirsz = 2;
  1118. X    userdirct = 0;
  1119. X    adduserdir("",home);
  1120. X    optarg = ztrdup("");
  1121. X    zoptind = 1;
  1122. X    schedcmds = NULL;
  1123. X    path = (char **) zalloc(4*sizeof *path);
  1124. X    path[0] = ztrdup("/bin"); path[1] = ztrdup("/usr/bin");
  1125. X    path[2] = ztrdup("/usr/ucb"); path[3] = NULL;
  1126. X    inittyptab();
  1127. X    initlextabs();
  1128. X    setupparams();
  1129. X    setparams();
  1130. X    inittyptab();
  1131. X    if ((s = zgetenv("EMACS")) && !strcmp(s,"t") && !strcmp(term,"emacs"))
  1132. X        opts[USEZLE] = OPT_UNSET;
  1133. X#ifndef HAS_RUSAGE
  1134. X    times(&shtms);
  1135. X#endif
  1136. X}
  1137. X
  1138. Xvoid compctlsetup() /**/
  1139. X{
  1140. Xstatic char
  1141. X    *hs[] = {"telnet","rlogin","ftp","rup","rusers","rsh",NULL},
  1142. X    *os[] = {"setopt","unsetopt",NULL},
  1143. X    *vs[] = {"export","typeset","vared","unset",NULL},
  1144. X    *cs[] = {"which","builtin",NULL},
  1145. X    *bs[] = {"bindkey",NULL};
  1146. X
  1147. X    compctl_process(hs,CC_HOSTS,NULL);
  1148. X    compctl_process(os,CC_OPTIONS,NULL);
  1149. X    compctl_process(vs,CC_VARS,NULL);
  1150. X    compctl_process(bs,CC_BINDINGS,NULL);
  1151. X    compctl_process(cs,CC_COMMPATH,NULL);
  1152. X    cc_compos.mask   = CC_COMMPATH;
  1153. X    cc_default.mask  = CC_FILES;
  1154. X}
  1155. X
  1156. Xvoid initialize() /**/
  1157. X{
  1158. Xint t0;
  1159. X#ifdef SYSVR4
  1160. X    static struct sigaction chldaction;
  1161. X#endif
  1162. X
  1163. X    breaks = loops = 0;
  1164. X    lastmailcheck = time(NULL);
  1165. X    locallist = NULL;
  1166. X    dirstack = newlist();
  1167. X    bufstack = newlist();
  1168. X    newcmdnamtab();
  1169. X    inbuf = zalloc(inbufsz = 256);
  1170. X    inbufptr = inbuf+inbufsz;
  1171. X    inbufct = 0;
  1172. X#ifndef QDEBUG
  1173. X    signal(SIGQUIT,SIG_IGN);
  1174. X#endif
  1175. X#ifdef RLIM_INFINITY
  1176. X    for (t0 = 0; t0 != RLIM_NLIMITS; t0++)
  1177. X        getrlimit(t0,limits+t0);
  1178. X#endif
  1179. X    hsubl = hsubr = NULL;
  1180. X    lastpid = 0;
  1181. X    bshin = fdopen(SHIN,"r");
  1182. X#ifdef SYSVR4
  1183. X    memset(&chldaction, 0, sizeof(chldaction));
  1184. X    chldaction.sa_handler = handler;
  1185. X    sigaction(SIGCHLD, &chldaction, NULL);
  1186. X#else
  1187. X    signal(SIGHUP,handler);
  1188. X    signal(SIGCHLD,handler);
  1189. X#endif
  1190. X    if (jobbing)
  1191. X        {
  1192. X        long ttypgrp;
  1193. X        while ((ttypgrp = gettygrp()) != -1 && ttypgrp != mypgrp)
  1194. X            kill(0,SIGTTIN);
  1195. X        if (ttypgrp == -1)
  1196. X            {
  1197. X            opts[MONITOR] = OPT_UNSET;
  1198. X            }
  1199. X        else
  1200. X            {
  1201. X            signal(SIGTTOU,SIG_IGN);
  1202. X            signal(SIGTSTP,SIG_IGN);
  1203. X            signal(SIGTTIN,SIG_IGN);
  1204. X            signal(SIGPIPE,SIG_IGN);
  1205. X            attachtty(mypgrp);
  1206. X            }
  1207. X        }
  1208. X    if (interact)
  1209. X        {
  1210. X        signal(SIGTERM,SIG_IGN);
  1211. X#ifdef SIGWINCH
  1212. X        signal(SIGWINCH,handler);
  1213. X#endif
  1214. X        signal(SIGALRM,handler);
  1215. X        intr();
  1216. X        }
  1217. X}
  1218. X
  1219. Xvoid addreswords() /**/
  1220. X{
  1221. Xstatic char *reswds[] = {
  1222. X    "do", "done", "esac", "then", "elif", "else", "fi", "for", "case",
  1223. X    "if", "while", "function", "repeat", "time", "until", "exec", "command",
  1224. X    "select", "coproc", "noglob", "-", "nocorrect", "foreach", "end", NULL
  1225. X    };
  1226. Xint t0;
  1227. X
  1228. X    for (t0 = 0; reswds[t0]; t0++)
  1229. X        addhperm(reswds[t0],mkanode(NULL,-1-t0),aliastab,(FFunc) 0);
  1230. X}
  1231. X
  1232. Xvoid runscripts(zshname) /**/
  1233. Xchar *zshname;
  1234. X{
  1235. X    /*
  1236. X       KSH Mode:
  1237. X       if called as "ksh", we source the standard
  1238. X       sh/ksh scripts:
  1239. X       wnp@rcvie.co.at 1992/05/14
  1240. X     */
  1241. X
  1242. X    if ( strcmp(zshname, "ksh") == 0 )
  1243. X    {
  1244. X        if (islogin) source("/etc/profile") ;
  1245. X        if (islogin) sourcehome(".profile");
  1246. X        source(getsparam("ENV"));
  1247. X    }
  1248. X    else if (isset(NORCS))
  1249. X    {
  1250. X#ifdef GLOBALZSHENV
  1251. X        source(GLOBALZSHENV);
  1252. X#endif
  1253. X    }
  1254. X    else
  1255. X    {
  1256. X#ifdef GLOBALZSHENV
  1257. X        source(GLOBALZSHENV);
  1258. X#endif
  1259. X        if (isset(NORCS)) {
  1260. X#ifdef GLOBALZPROFILE
  1261. X            if (islogin) source(GLOBALZPROFILE);
  1262. X#endif
  1263. X#ifdef GLOBALZSHRC
  1264. X            if (! isset(NORCS))
  1265. X                source(GLOBALZSHRC);
  1266. X#endif
  1267. X#ifdef GLOBALZLOGIN
  1268. X            if (islogin && ! isset(NORCS))
  1269. X                source(GLOBALZLOGIN);
  1270. X#endif
  1271. X        } else {
  1272. X            sourcehome(".zshenv");
  1273. X            if (interact && ! isset(NORCS)) {
  1274. X                if (islogin) {
  1275. X#ifdef GLOBALZPROFILE
  1276. X                    source(GLOBALZPROFILE);
  1277. X                    if (! isset(NORCS))
  1278. X#endif
  1279. X                        sourcehome(".zprofile");
  1280. X                }
  1281. X#ifdef GLOBALZSHRC
  1282. X                if (! isset(NORCS))
  1283. X                    source(GLOBALZSHRC);
  1284. X                if (! isset(NORCS))
  1285. X#endif
  1286. X                    sourcehome(".zshrc");
  1287. X                if (islogin && ! isset(NORCS)) {
  1288. X#ifdef GLOBALZLOGIN
  1289. X                    source(GLOBALZLOGIN);
  1290. X                    if (! isset(NORCS))
  1291. X#endif
  1292. X                        sourcehome(".zlogin");
  1293. X                }
  1294. X            }
  1295. X        }
  1296. X    }
  1297. X    if (isset('c'))
  1298. X        {
  1299. X        if (SHIN >= 10)
  1300. X            close(SHIN);
  1301. X        SHIN = movefd(open("/dev/null",O_RDONLY));
  1302. X        execstring(cmd);
  1303. X        stopmsg = 1;
  1304. X        zexit(lastval);
  1305. X        }
  1306. X    if (interact && ! isset(NORCS))
  1307. X        readhistfile(getsparam("HISTFILE"),0);
  1308. X#ifdef TIOCSWINSZ
  1309. X    if (!(columns = shttyinfo.winsize.ws_col))
  1310. X        columns = 80;
  1311. X    if (!(lines = shttyinfo.winsize.ws_row))
  1312. X        lines = 24;
  1313. X#endif
  1314. X}
  1315. X
  1316. Xvoid ainit() /**/
  1317. X{
  1318. X    alstackind = 0;        /* reset alias stack */
  1319. X    alstat = 0;
  1320. X    isfirstln = 1;
  1321. X}
  1322. END_OF_FILE
  1323.   if test 14274 -ne `wc -c <'src/init.c'`; then
  1324.     echo shar: \"'src/init.c'\" unpacked with wrong size!
  1325.   fi
  1326.   # end of 'src/init.c'
  1327. fi
  1328. if test -f 'src/zle_bindings.c' -a "${1}" != "-c" ; then 
  1329.   echo shar: Will not clobber existing file \"'src/zle_bindings.c'\"
  1330. else
  1331.   echo shar: Extracting \"'src/zle_bindings.c'\" \(17791 characters\)
  1332.   sed "s/^X//" >'src/zle_bindings.c' <<'END_OF_FILE'
  1333. X/*
  1334. X *
  1335. X * zle_bindings.c - commands and keymaps
  1336. X *
  1337. X * This file is part of zsh, the Z shell.
  1338. X *
  1339. X * This software is Copyright 1992 by Paul Falstad
  1340. X *
  1341. X * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  1342. X * use this software as long as: there is no monetary profit gained
  1343. X * specifically from the use or reproduction of this software, it is not
  1344. X * sold, rented, traded or otherwise marketed, and this copyright notice is
  1345. X * included prominently in any copy made. 
  1346. X *
  1347. X * The author make no claims as to the fitness or correctness of this software
  1348. X * for any use whatsoever, and it is provided as is. Any use of this software
  1349. X * is at the user's own risk. 
  1350. X *
  1351. X */
  1352. X
  1353. X#define ZLE
  1354. X#include "zsh.h"
  1355. X
  1356. X
  1357. Xstruct zlecmd zlecmds[] = {
  1358. X{"accept-and-hold",acceptandhold,0},
  1359. X{"accept-and-infer-next-history",acceptandinfernexthistory,0},
  1360. X{"accept-and-menu-complete", acceptandmenucomplete, ZLE_MENUCMP},
  1361. X{"accept-line",acceptline,0},
  1362. X{"accept-line-and-down-history",acceptlineanddownhistory,0},
  1363. X{"backward-char",backwardchar,ZLE_MOVEMENT},
  1364. X{"backward-delete-char",backwarddeletechar,ZLE_DELETE},
  1365. X{"backward-delete-word",backwarddeleteword,ZLE_DELETE},
  1366. X{"backward-kill-line",backwardkillline,ZLE_KILL},
  1367. X{"backward-kill-word",backwardkillword,ZLE_KILL|ZLE_DELETE},
  1368. X{"backward-word",backwardword,ZLE_MOVEMENT},
  1369. X{"beginning-of-buffer-or-history",beginningofbufferorhistory,ZLE_MOVEMENT},
  1370. X{"beginning-of-history",beginningofhistory,0},
  1371. X{"beginning-of-line",beginningofline,ZLE_MOVEMENT},
  1372. X{"beginning-of-line-hist",beginningoflinehist,ZLE_MOVEMENT},
  1373. X{"capitalize-word",capitalizeword,0},
  1374. X{"clear-screen",clearscreen,0},
  1375. X{"complete-word",completeword,ZLE_MENUCMP},
  1376. X{"copy-prev-word",copyprevword,0},
  1377. X{"copy-region-as-kill",copyregionaskill,ZLE_KILL},
  1378. X{"delete-char",deletechar,ZLE_DELETE},
  1379. X{"delete-char-or-list",deletecharorlist,ZLE_MENUCMP},
  1380. X{"delete-word",deleteword,ZLE_DELETE},
  1381. X{"digit-argument",digitargument,ZLE_ARG},
  1382. X{"down-case-word",downcaseword,0},
  1383. X{"down-history",downhistory,0},
  1384. X{"down-line-or-history",downlineorhistory,ZLE_MOVEMENT|ZLE_LINEMOVE},
  1385. X{"end-of-buffer-or-history",endofbufferorhistory,ZLE_MOVEMENT},
  1386. X{"end-of-history",endofhistory,0},
  1387. X{"end-of-line",endofline,ZLE_MOVEMENT},
  1388. X{"end-of-line-hist",endoflinehist,ZLE_MOVEMENT},
  1389. X{"exchange-point-and-mark",exchangepointandmark,ZLE_MOVEMENT},
  1390. X{"execute-last-named-cmd",(F) 0,0},
  1391. X{"execute-named-cmd",(F) 0,0},
  1392. X{"expand-history",expandhistory,0},
  1393. X{"expand-or-complete",expandorcomplete,ZLE_MENUCMP},
  1394. X{"expand-word",expandword,0},
  1395. X{"forward-char",forwardchar,ZLE_MOVEMENT},
  1396. X{"forward-word",forwardword,ZLE_MOVEMENT},
  1397. X{"get-line",getline,0},
  1398. X{"gosmacs-transpose-chars",gosmacstransposechars,0},
  1399. X{"history-incremental-search-backward",historyincrementalsearchbackward,0},
  1400. X{"history-incremental-search-forward",historyincrementalsearchforward,0},
  1401. X{"history-search-backward",historysearchbackward,ZLE_HISTSEARCH},
  1402. X{"history-search-forward",historysearchforward,ZLE_HISTSEARCH},
  1403. X{"infer-next-history",infernexthistory,0},
  1404. X{"insert-last-word",insertlastword,ZLE_INSERT},
  1405. X{"kill-buffer",killbuffer,ZLE_KILL},
  1406. X{"kill-line",killline,ZLE_KILL},
  1407. X{"kill-region",killregion,ZLE_KILL},
  1408. X{"kill-whole-line",killwholeline,ZLE_KILL},
  1409. X{"list-choices",listchoices,ZLE_DELETE},    /* ZLE_DELETE fixes autoremoveslash */
  1410. X{"list-expand",listexpand,ZLE_MENUCMP},
  1411. X{"magic-space",magicspace,0},
  1412. X{"menu-complete",menucompleteword,ZLE_MENUCMP},
  1413. X{"menu-expand-or-complete",menuexpandorcomplete,ZLE_MENUCMP},
  1414. X{"overwrite-mode",overwritemode,0},
  1415. X{"push-line",pushline,0},
  1416. X{"quoted-insert",quotedinsert,ZLE_INSERT},
  1417. X{"quote-line",quoteline,0},
  1418. X{"quote-region",quoteregion,0},
  1419. X{"redisplay",redisplay,0},
  1420. X{"reverse-menu-complete",reversemenucomplete,ZLE_MENUCMP},
  1421. X{"run-help",processcmd,0},
  1422. X{"self-insert",selfinsert,ZLE_INSERT},
  1423. X{"self-insert-unmeta",selfinsertunmeta,ZLE_INSERT},
  1424. X{"send-break",sendbreak,0},
  1425. X{"send-string",sendstring,0},
  1426. X{"",(F) 0,0},
  1427. X{"set-mark-command",setmarkcommand,0},
  1428. X{"spell-word",spellword,0},
  1429. X{"toggle-literal-history",toggleliteralhistory,0},
  1430. X{"transpose-chars",transposechars,0},
  1431. X{"transpose-words",transposewords,0},
  1432. X{"undefined-key",undefinedkey,0},
  1433. X{"undo",undo,ZLE_UNDO},
  1434. X{"universal-argument",universalargument,ZLE_ARG},
  1435. X{"up-case-word",upcaseword,0},
  1436. X{"up-history",uphistory,0},
  1437. X{"up-line-or-history",uplineorhistory,ZLE_LINEMOVE|ZLE_MOVEMENT},
  1438. X{"vi-add-eol",viaddeol,0},
  1439. X{"vi-add-next",viaddnext,0},
  1440. X{"vi-backward-blank-word",vibackwardblankword,ZLE_MOVEMENT},
  1441. X{"vi-backward-char",vibackwardchar,ZLE_MOVEMENT},
  1442. X{"vi-backward-delete-char",vibackwarddeletechar,ZLE_KILL},
  1443. X{"vi-beginning-of-line",vibeginningofline,ZLE_MOVEMENT},
  1444. X{"vi-caps-lock-panic",vicapslockpanic,0},
  1445. X{"vi-change",vichange,0},
  1446. X{"vi-change-eol",vichangeeol,0},
  1447. X{"vi-change-whole-line",vichangewholeline,0},
  1448. X{"vi-cmd-mode",vicmdmode,0},
  1449. X{"vi-delete",videlete,ZLE_KILL},
  1450. X{"vi-delete-char",videletechar,ZLE_KILL},
  1451. X{"vi-digit-or-beginning-of-line",(F) 0,0},
  1452. X{"vi-end-of-line",viendofline,ZLE_MOVEMENT},
  1453. X{"vi-fetch-history",vifetchhistory,0},
  1454. X{"vi-find-next-char",vifindnextchar,ZLE_MOVEMENT},
  1455. X{"vi-find-next-char-skip",vifindnextcharskip,ZLE_MOVEMENT},
  1456. X{"vi-find-prev-char",vifindprevchar,ZLE_MOVEMENT},
  1457. X{"vi-find-prev-char-skip",vifindprevcharskip,ZLE_MOVEMENT},
  1458. X{"vi-first-non-blank",vifirstnonblank,ZLE_MOVEMENT},
  1459. X{"vi-forward-blank-word",viforwardblankword,ZLE_MOVEMENT},
  1460. X{"vi-forward-blank-word-end",viforwardblankwordend,ZLE_MOVEMENT},
  1461. X{"vi-forward-char",viforwardchar,ZLE_MOVEMENT},
  1462. X{"vi-forward-word-end",viforwardwordend,ZLE_MOVEMENT},
  1463. X{"vi-goto-column",vigotocolumn,ZLE_MOVEMENT},
  1464. X{"vi-goto-mark",vigotomark,ZLE_MOVEMENT},
  1465. X{"vi-goto-mark-line",vigotomarkline,ZLE_MOVEMENT},
  1466. X{"vi-history-search-backward",vihistorysearchbackward,0},
  1467. X{"vi-history-search-forward",vihistorysearchforward,0},
  1468. X{"vi-indent",viindent,0},
  1469. X{"vi-insert",viinsert,0},
  1470. X{"vi-insert-bol",viinsertbol,0},
  1471. X{"vi-join",vijoin,0},
  1472. X{"vi-match-bracket",vimatchbracket,ZLE_MOVEMENT},
  1473. X{"vi-open-line-above",viopenlineabove,0},
  1474. X{"vi-open-line-below",viopenlinebelow,0},
  1475. X{"vi-oper-swap-case",vioperswapcase,0},
  1476. X{"vi-put-after",viputafter,ZLE_YANK},
  1477. X{"vi-repeat-change",virepeatchange,ZLE_ARG},
  1478. X{"vi-repeat-find",virepeatfind,ZLE_MOVEMENT},
  1479. X{"vi-repeat-search",virepeatsearch,ZLE_MOVEMENT},
  1480. X{"vi-replace",vireplace,0},
  1481. X{"vi-replace-chars",vireplacechars,0},
  1482. X{"vi-rev-repeat-find",virevrepeatfind,ZLE_MOVEMENT},
  1483. X{"vi-rev-repeat-search",virevrepeatsearch,ZLE_MOVEMENT},
  1484. X{"vi-set-buffer",visetbuffer,0},
  1485. X{"vi-set-mark",visetmark,0},
  1486. X{"vi-substitute",visubstitute,0},
  1487. X{"vi-swap-case",viswapcase,0},
  1488. X{"vi-undo-change",undo,0},
  1489. X{"vi-unindent",viunindent,0},
  1490. X{"vi-yank",viyank,0},
  1491. X{"vi-yank-eol",viyankeol,0},
  1492. X{"which-command",processcmd,0},
  1493. X{"yank",yank,ZLE_YANK|ZLE_NAMEDBUFFER},
  1494. X{"yank-pop",yankpop,ZLE_YANK},
  1495. X{"emacs-forward-word",emacsforwardword,ZLE_MOVEMENT},
  1496. X{"emacs-backward-word",emacsbackwardword,ZLE_MOVEMENT},
  1497. X{"kill-word",killword,ZLE_KILL},
  1498. X{"vi-kill-line",vikillline,0},
  1499. X{"vi-backward-kill-word",vibackwardkillword,ZLE_KILL},
  1500. X{"expand-cmd-path",expandcmdpath,0},
  1501. X{"neg-argument",negargument,ZLE_NEGARG|ZLE_ARG},
  1502. X{"pound-insert",poundinsert,0},
  1503. X{"vi-forward-word",viforwardword,ZLE_MOVEMENT},
  1504. X{"vi-backward-word",vibackwardword,ZLE_MOVEMENT},
  1505. X{"up-line-or-search",uplineorsearch,ZLE_MOVEMENT|ZLE_LINEMOVE|ZLE_HISTSEARCH},
  1506. X{"down-line-or-search",downlineorsearch,ZLE_MOVEMENT|ZLE_LINEMOVE|ZLE_HISTSEARCH},
  1507. X{"",(F) 0,0}
  1508. X};
  1509. X
  1510. Xint emacsbind[256] = {
  1511. X/* ^@ */ z_setmarkcommand,
  1512. X/* ^A */ z_beginningofline,
  1513. X/* ^B */ z_backwardchar,
  1514. X/* ^C */ z_sendbreak,
  1515. X/* ^D */ z_deletecharorlist,
  1516. X/* ^E */ z_endofline,
  1517. X/* ^F */ z_forwardchar,
  1518. X/* ^G */ z_undefinedkey,
  1519. X/* ^H */ z_backwarddeletechar,
  1520. X/* ^I */ z_expandorcomplete,
  1521. X/* ^J */ z_acceptline,
  1522. X/* ^K */ z_killline,
  1523. X/* ^L */ z_clearscreen,
  1524. X/* ^M */ z_acceptline,
  1525. X/* ^N */ z_downlineorhistory,
  1526. X/* ^O */ z_acceptlineanddownhistory,
  1527. X/* ^P */ z_uplineorhistory,
  1528. X/* ^Q */ z_pushline,
  1529. X/* ^R */ z_historyincrementalsearchbackward,
  1530. X/* ^S */ z_historyincrementalsearchforward,
  1531. X/* ^T */ z_transposechars,
  1532. X/* ^U */ z_killwholeline,
  1533. X/* ^V */ z_quotedinsert,
  1534. X/* ^W */ z_backwardkillword,
  1535. X/* ^X */ z_sequenceleadin,
  1536. X/* ^Y */ z_yank,
  1537. X/* ^Z */ z_undefinedkey,
  1538. X/* ^[ */ z_sequenceleadin,
  1539. X/* ^\ */ z_undefinedkey,
  1540. X/* ^] */ z_undefinedkey,
  1541. X/* ^^ */ z_undefinedkey,
  1542. X/* ^_ */ z_undo,
  1543. X/*   */ z_selfinsert,
  1544. X/* ! */ z_selfinsert,
  1545. X/* " */ z_selfinsert,
  1546. X/* # */ z_selfinsert,
  1547. X/* $ */ z_selfinsert,
  1548. X/* % */ z_selfinsert,
  1549. X/* & */ z_selfinsert,
  1550. X/* ' */ z_selfinsert,
  1551. X/* ( */ z_selfinsert,
  1552. X/* ) */ z_selfinsert,
  1553. X/* * */ z_selfinsert,
  1554. X/* + */ z_selfinsert,
  1555. X/* , */ z_selfinsert,
  1556. X/* - */ z_selfinsert,
  1557. X/* . */ z_selfinsert,
  1558. X/* / */ z_selfinsert,
  1559. X/* 0 */ z_selfinsert,
  1560. X/* 1 */ z_selfinsert,
  1561. X/* 2 */ z_selfinsert,
  1562. X/* 3 */ z_selfinsert,
  1563. X/* 4 */ z_selfinsert,
  1564. X/* 5 */ z_selfinsert,
  1565. X/* 6 */ z_selfinsert,
  1566. X/* 7 */ z_selfinsert,
  1567. X/* 8 */ z_selfinsert,
  1568. X/* 9 */ z_selfinsert,
  1569. X/* : */ z_selfinsert,
  1570. X/* ; */ z_selfinsert,
  1571. X/* < */ z_selfinsert,
  1572. X/* = */ z_selfinsert,
  1573. X/* > */ z_selfinsert,
  1574. X/* ? */ z_selfinsert,
  1575. X/* @ */ z_selfinsert,
  1576. X/* A */ z_selfinsert,
  1577. X/* B */ z_selfinsert,
  1578. X/* C */ z_selfinsert,
  1579. X/* D */ z_selfinsert,
  1580. X/* E */ z_selfinsert,
  1581. X/* F */ z_selfinsert,
  1582. X/* G */ z_selfinsert,
  1583. X/* H */ z_selfinsert,
  1584. X/* I */ z_selfinsert,
  1585. X/* J */ z_selfinsert,
  1586. X/* K */ z_selfinsert,
  1587. X/* L */ z_selfinsert,
  1588. X/* M */ z_selfinsert,
  1589. X/* N */ z_selfinsert,
  1590. X/* O */ z_selfinsert,
  1591. X/* P */ z_selfinsert,
  1592. X/* Q */ z_selfinsert,
  1593. X/* R */ z_selfinsert,
  1594. X/* S */ z_selfinsert,
  1595. X/* T */ z_selfinsert,
  1596. X/* U */ z_selfinsert,
  1597. X/* V */ z_selfinsert,
  1598. X/* W */ z_selfinsert,
  1599. X/* X */ z_selfinsert,
  1600. X/* Y */ z_selfinsert,
  1601. X/* Z */ z_selfinsert,
  1602. X/* [ */ z_selfinsert,
  1603. X/* \ */ z_selfinsert,
  1604. X/* ] */ z_selfinsert,
  1605. X/* ^ */ z_selfinsert,
  1606. X/* _ */ z_selfinsert,
  1607. X/* ` */ z_selfinsert,
  1608. X/* a */ z_selfinsert,
  1609. X/* b */ z_selfinsert,
  1610. X/* c */ z_selfinsert,
  1611. X/* d */ z_selfinsert,
  1612. X/* e */ z_selfinsert,
  1613. X/* f */ z_selfinsert,
  1614. X/* g */ z_selfinsert,
  1615. X/* h */ z_selfinsert,
  1616. X/* i */ z_selfinsert,
  1617. X/* j */ z_selfinsert,
  1618. X/* k */ z_selfinsert,
  1619. X/* l */ z_selfinsert,
  1620. X/* m */ z_selfinsert,
  1621. X/* n */ z_selfinsert,
  1622. X/* o */ z_selfinsert,
  1623. X/* p */ z_selfinsert,
  1624. X/* q */ z_selfinsert,
  1625. X/* r */ z_selfinsert,
  1626. X/* s */ z_selfinsert,
  1627. X/* t */ z_selfinsert,
  1628. X/* u */ z_selfinsert,
  1629. X/* v */ z_selfinsert,
  1630. X/* w */ z_selfinsert,
  1631. X/* x */ z_selfinsert,
  1632. X/* y */ z_selfinsert,
  1633. X/* z */ z_selfinsert,
  1634. X/* { */ z_selfinsert,
  1635. X/* | */ z_selfinsert,
  1636. X/* } */ z_selfinsert,
  1637. X/* ~ */ z_selfinsert,
  1638. X/* ^? */ z_backwarddeletechar,
  1639. X/* M-^@ */ z_undefinedkey,
  1640. X/* M-^A */ z_undefinedkey,
  1641. X/* M-^B */ z_undefinedkey,
  1642. X/* M-^C */ z_undefinedkey,
  1643. X/* M-^D */ z_listchoices,
  1644. X/* M-^E */ z_undefinedkey,
  1645. X/* M-^F */ z_undefinedkey,
  1646. X/* M-^G */ z_undefinedkey,
  1647. X/* M-^H */ z_backwardkillword,
  1648. X/* M-^I */ z_selfinsertunmeta,
  1649. X/* M-^J */ z_selfinsertunmeta,
  1650. X/* M-^K */ z_undefinedkey,
  1651. X/* M-^L */ z_clearscreen,
  1652. X/* M-^M */ z_selfinsertunmeta,
  1653. X/* M-^N */ z_undefinedkey,
  1654. X/* M-^O */ z_undefinedkey,
  1655. X/* M-^P */ z_undefinedkey,
  1656. X/* M-^Q */ z_undefinedkey,
  1657. X/* M-^R */ z_undefinedkey,
  1658. X/* M-^S */ z_undefinedkey,
  1659. X/* M-^T */ z_undefinedkey,
  1660. X/* M-^U */ z_undefinedkey,
  1661. X/* M-^V */ z_undefinedkey,
  1662. X/* M-^W */ z_undefinedkey,
  1663. X/* M-^X */ z_undefinedkey,
  1664. X/* M-^Y */ z_undefinedkey,
  1665. X/* M-^Z */ z_undefinedkey,
  1666. X/* M-^[ */ z_undefinedkey,
  1667. X/* M-^\ */ z_undefinedkey,
  1668. X/* M-^] */ z_undefinedkey,
  1669. X/* M-^^ */ z_undefinedkey,
  1670. X/* M-^_ */ z_copyprevword,
  1671. X/* M-  */ z_expandhistory,
  1672. X/* M-! */ z_expandhistory,
  1673. X/* M-" */ z_quoteregion,
  1674. X/* M-# */ z_undefinedkey,
  1675. X/* M-$ */ z_spellword,
  1676. X/* M-% */ z_undefinedkey,
  1677. X/* M-& */ z_undefinedkey,
  1678. X/* M-' */ z_quoteline,
  1679. X/* M-( */ z_undefinedkey,
  1680. X/* M-) */ z_undefinedkey,
  1681. X/* M-* */ z_undefinedkey,
  1682. X/* M-+ */ z_undefinedkey,
  1683. X/* M-, */ z_undefinedkey,
  1684. X/* M-- */ z_negargument,
  1685. X/* M-. */ z_insertlastword,
  1686. X/* M-/ */ z_undefinedkey,
  1687. X/* M-0 */ z_digitargument,
  1688. X/* M-1 */ z_digitargument,
  1689. X/* M-2 */ z_digitargument,
  1690. X/* M-3 */ z_digitargument,
  1691. X/* M-4 */ z_digitargument,
  1692. X/* M-5 */ z_digitargument,
  1693. X/* M-6 */ z_digitargument,
  1694. X/* M-7 */ z_digitargument,
  1695. X/* M-8 */ z_digitargument,
  1696. X/* M-9 */ z_digitargument,
  1697. X/* M-: */ z_undefinedkey,
  1698. X/* M-; */ z_undefinedkey,
  1699. X/* M-< */ z_beginningofbufferorhistory,
  1700. X/* M-= */ z_undefinedkey,
  1701. X/* M-> */ z_endofbufferorhistory,
  1702. X/* M-? */ z_whichcommand,
  1703. X/* M-@ */ z_undefinedkey,
  1704. X/* M-A */ z_acceptandhold,
  1705. X/* M-B */ z_backwardword,
  1706. X/* M-C */ z_capitalizeword,
  1707. X/* M-D */ z_deleteword,
  1708. X/* M-E */ z_undefinedkey,
  1709. X/* M-F */ z_forwardword,
  1710. X/* M-G */ z_getline,
  1711. X/* M-H */ z_runhelp,
  1712. X/* M-I */ z_undefinedkey,
  1713. X/* M-J */ z_undefinedkey,
  1714. X/* M-K */ z_undefinedkey,
  1715. X/* M-L */ z_downcaseword,
  1716. X/* M-M */ z_undefinedkey,
  1717. X/* M-N */ z_historysearchforward,
  1718. X/* M-O */ z_undefinedkey,
  1719. X/* M-P */ z_historysearchbackward,
  1720. X/* M-Q */ z_pushline,
  1721. X/* M-R */ z_toggleliteralhistory,
  1722. X/* M-S */ z_spellword,
  1723. X/* M-T */ z_transposewords,
  1724. X/* M-U */ z_upcaseword,
  1725. X/* M-V */ z_undefinedkey,
  1726. X/* M-W */ z_copyregionaskill,
  1727. X/* M-X */ z_undefinedkey,
  1728. X/* M-Y */ z_undefinedkey,
  1729. X/* M-Z */ z_undefinedkey,
  1730. X/* M-[ */ z_sequenceleadin,
  1731. X/* M-\ */ z_undefinedkey,
  1732. X/* M-] */ z_undefinedkey,
  1733. X/* M-^ */ z_undefinedkey,
  1734. X/* M-_ */ z_insertlastword,
  1735. X/* M-` */ z_undefinedkey,
  1736. X/* M-a */ z_acceptandhold,
  1737. X/* M-b */ z_backwardword,
  1738. X/* M-c */ z_capitalizeword,
  1739. X/* M-d */ z_deleteword,
  1740. X/* M-e */ z_undefinedkey,
  1741. X/* M-f */ z_forwardword,
  1742. X/* M-g */ z_getline,
  1743. X/* M-h */ z_runhelp,
  1744. X/* M-i */ z_undefinedkey,
  1745. X/* M-j */ z_undefinedkey,
  1746. X/* M-k */ z_undefinedkey,
  1747. X/* M-l */ z_downcaseword,
  1748. X/* M-m */ z_undefinedkey,
  1749. X/* M-n */ z_historysearchforward,
  1750. X/* M-o */ z_undefinedkey,
  1751. X/* M-p */ z_historysearchbackward,
  1752. X/* M-q */ z_pushline,
  1753. X/* M-r */ z_toggleliteralhistory,
  1754. X/* M-s */ z_spellword,
  1755. X/* M-t */ z_transposewords,
  1756. X/* M-u */ z_upcaseword,
  1757. X/* M-v */ z_undefinedkey,
  1758. X/* M-w */ z_copyregionaskill,
  1759. X/* M-x */ z_executenamedcmd,
  1760. X/* M-y */ z_yankpop,
  1761. X/* M-z */ z_executelastnamedcmd,
  1762. X/* M-{ */ z_undefinedkey,
  1763. X/* M-| */ z_vigotocolumn,
  1764. X/* M-} */ z_undefinedkey,
  1765. X/* M-~ */ z_undefinedkey,
  1766. X/* M-^? */ z_backwardkillword,
  1767. X};
  1768. X
  1769. Xint viinsbind[32] = {
  1770. X/* ^@ */ z_undefinedkey,
  1771. X/* ^A */ z_selfinsert,
  1772. X/* ^B */ z_selfinsert,
  1773. X/* ^C */ z_sendbreak,
  1774. X/* ^D */ z_listchoices,
  1775. X/* ^E */ z_selfinsert,
  1776. X/* ^F */ z_selfinsert,
  1777. X/* ^G */ z_selfinsert,
  1778. X/* ^H */ z_vibackwarddeletechar,
  1779. X/* ^I */ z_expandorcomplete,
  1780. X/* ^J */ z_acceptline,
  1781. X/* ^K */ z_killline,
  1782. X/* ^L */ z_clearscreen,
  1783. X/* ^M */ z_acceptline,
  1784. X/* ^N */ z_selfinsert,
  1785. X/* ^O */ z_selfinsert,
  1786. X/* ^P */ z_selfinsert,
  1787. X/* ^Q */ z_selfinsert,
  1788. X/* ^R */ z_redisplay,
  1789. X/* ^S */ z_selfinsert,
  1790. X/* ^T */ z_selfinsert,
  1791. X/* ^U */ z_vikillline,
  1792. X/* ^V */ z_quotedinsert,
  1793. X/* ^W */ z_vibackwardkillword,
  1794. X/* ^X */ z_selfinsert,
  1795. X/* ^Y */ z_selfinsert,
  1796. X/* ^Z */ z_selfinsert,
  1797. X/* ^[ */ z_vicmdmode,
  1798. X/* ^\ */ z_selfinsert,
  1799. X/* ^] */ z_selfinsert,
  1800. X/* ^^ */ z_selfinsert,
  1801. X/* ^_ */ z_selfinsert,
  1802. X};
  1803. X
  1804. Xint vicmdbind[128] = {
  1805. X/* ^@ */ z_undefinedkey,
  1806. X/* ^A */ z_beginningofline,
  1807. X/* ^B */ z_undefinedkey,
  1808. X/* ^C */ z_sendbreak,
  1809. X/* ^D */ z_listchoices,
  1810. X/* ^E */ z_endofline,
  1811. X/* ^F */ z_undefinedkey,
  1812. X/* ^G */ z_listexpand,
  1813. X/* ^H */ z_backwarddeletechar,
  1814. X/* ^I */ z_completeword,
  1815. X/* ^J */ z_acceptline,
  1816. X/* ^K */ z_killline,
  1817. X/* ^L */ z_clearscreen,
  1818. X/* ^M */ z_acceptline,
  1819. X/* ^N */ z_downhistory,
  1820. X/* ^O */ z_undefinedkey,
  1821. X/* ^P */ z_uphistory,
  1822. X/* ^Q */ z_undefinedkey,
  1823. X/* ^R */ z_redisplay,
  1824. X/* ^S */ z_undefinedkey,
  1825. X/* ^T */ z_undefinedkey,
  1826. X/* ^U */ z_killbuffer,
  1827. X/* ^V */ z_undefinedkey,
  1828. X/* ^W */ z_backwardkillword,
  1829. X/* ^X */ z_expandorcomplete,
  1830. X/* ^Y */ z_undefinedkey,
  1831. X/* ^Z */ z_undefinedkey,
  1832. X/* ^[ */ z_sequenceleadin,
  1833. X/* ^\ */ z_undefinedkey,
  1834. X/* ^] */ z_undefinedkey,
  1835. X/* ^^ */ z_undefinedkey,
  1836. X/* ^_ */ z_undefinedkey,
  1837. X/*   */ z_viforwardchar,
  1838. X/* ! */ z_undefinedkey,
  1839. X/* " */ z_visetbuffer,
  1840. X/* # */ z_poundinsert,
  1841. X/* $ */ z_viendofline,
  1842. X/* % */ z_vimatchbracket,
  1843. X/* & */ z_undefinedkey,
  1844. X/* ' */ z_vigotomarkline,
  1845. X/* ( */ z_undefinedkey,
  1846. X/* ) */ z_undefinedkey,
  1847. X/* * */ z_undefinedkey,
  1848. X/* + */ z_downlineorhistory,
  1849. X/* , */ z_virevrepeatfind,
  1850. X/* - */ z_uplineorhistory,
  1851. X/* . */ z_virepeatchange,
  1852. X/* / */ z_vihistorysearchbackward,
  1853. X/* 0 */ z_vidigitorbeginningofline,
  1854. X/* 1 */ z_digitargument,
  1855. X/* 2 */ z_digitargument,
  1856. X/* 3 */ z_digitargument,
  1857. X/* 4 */ z_digitargument,
  1858. X/* 5 */ z_digitargument,
  1859. X/* 6 */ z_digitargument,
  1860. X/* 7 */ z_digitargument,
  1861. X/* 8 */ z_digitargument,
  1862. X/* 9 */ z_digitargument,
  1863. X/* : */ z_undefinedkey,
  1864. X/* ; */ z_virepeatfind,
  1865. X/* < */ z_viunindent,
  1866. X/* = */ z_listchoices,
  1867. X/* > */ z_viindent,
  1868. X/* ? */ z_vihistorysearchforward,
  1869. X/* @ */ z_undefinedkey,
  1870. X/* A */ z_viaddeol,
  1871. X/* B */ z_vibackwardblankword,
  1872. X/* C */ z_vichangeeol,
  1873. X/* D */ z_killline,
  1874. X/* E */ z_viforwardblankwordend,
  1875. X/* F */ z_vifindprevchar,
  1876. X/* G */ z_vifetchhistory,
  1877. X/* H */ z_vicapslockpanic,
  1878. X/* I */ z_viinsertbol,
  1879. X/* J */ z_historysearchforward,
  1880. X/* K */ z_historysearchbackward,
  1881. X/* L */ z_undefinedkey,
  1882. X/* M */ z_undefinedkey,
  1883. X/* N */ z_virevrepeatsearch,
  1884. X/* O */ z_viopenlineabove,
  1885. X/* P */ z_yank,
  1886. X/* Q */ z_undefinedkey,
  1887. X/* R */ z_vireplace,
  1888. X/* S */ z_vichangewholeline,
  1889. X/* T */ z_vifindprevcharskip,
  1890. X/* U */ z_undefinedkey,
  1891. X/* V */ z_undefinedkey,
  1892. X/* W */ z_viforwardblankword,
  1893. X/* X */ z_vibackwarddeletechar,
  1894. X/* Y */ z_viyankeol,
  1895. X/* Z */ z_undefinedkey,
  1896. X/* [ */ z_undefinedkey,
  1897. X/* \ */ z_completeword,
  1898. X/* ] */ z_undefinedkey,
  1899. X/* ^ */ z_vifirstnonblank,
  1900. X/* _ */ z_undefinedkey,
  1901. X/* ` */ z_vigotomark,
  1902. X/* a */ z_viaddnext,
  1903. X/* b */ z_vibackwardword,
  1904. X/* c */ z_vichange,
  1905. X/* d */ z_videlete,
  1906. X/* e */ z_viforwardwordend,
  1907. X/* f */ z_vifindnextchar,
  1908. X/* g */ z_undefinedkey,
  1909. X/* h */ z_vibackwardchar,
  1910. X/* i */ z_viinsert,
  1911. X/* j */ z_downlineorhistory,
  1912. X/* k */ z_uplineorhistory,
  1913. X/* l */ z_viforwardchar,
  1914. X/* m */ z_visetmark,
  1915. X/* n */ z_virepeatsearch,
  1916. X/* o */ z_viopenlinebelow,
  1917. X/* p */ z_viputafter,
  1918. X/* q */ z_undefinedkey,
  1919. X/* r */ z_vireplacechars,
  1920. X/* s */ z_visubstitute,
  1921. X/* t */ z_vifindnextcharskip,
  1922. X/* u */ z_viundochange,
  1923. X/* v */ z_undefinedkey,
  1924. X/* w */ z_viforwardword,
  1925. X/* x */ z_videletechar,
  1926. X/* y */ z_viyank,
  1927. X/* z */ z_undefinedkey,
  1928. X/* { */ z_undefinedkey,
  1929. X/* | */ z_vigotocolumn,
  1930. X/* } */ z_undefinedkey,
  1931. X/* ~ */ z_viswapcase,
  1932. X/* ^? */ z_backwarddeletechar,
  1933. X};
  1934. X
  1935. END_OF_FILE
  1936.   if test 17791 -ne `wc -c <'src/zle_bindings.c'`; then
  1937.     echo shar: \"'src/zle_bindings.c'\" unpacked with wrong size!
  1938.   fi
  1939.   # end of 'src/zle_bindings.c'
  1940. fi
  1941. echo shar: End of archive 16 \(of 22\).
  1942. cp /dev/null ark16isdone
  1943. MISSING=""
  1944. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ; do
  1945.     if test ! -f ark${I}isdone ; then
  1946.     MISSING="${MISSING} ${I}"
  1947.     fi
  1948. done
  1949. if test "${MISSING}" = "" ; then
  1950.     echo You have unpacked all 22 archives.
  1951.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1952. else
  1953.     echo You still must unpack the following archives:
  1954.     echo "        " ${MISSING}
  1955. fi
  1956. exit 0
  1957.  
  1958. exit 0 # Just in case...
  1959.