home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
k
/
ksh48.zip
/
patches.os2
< prev
next >
Wrap
Text File
|
1992-09-26
|
57KB
|
2,301 lines
Only in new: patches.os2
Only in new/sh: Makefile
Only in new/sh: ksh.def
Only in new/sh: os2.c
diff -cbr orig/sh/alloc.c new/sh/alloc.c
*** orig/sh/alloc.c Sun May 03 18:45:01 1992
--- new/sh/alloc.c Sun May 03 18:47:14 1992
***************
*** 8,13 ****
--- 8,14 ----
#include "stdh.h"
#include <setjmp.h>
+ #include <sys/types.h>
#include "sh.h"
#define ICELLS 100 /* number of Cells in small Block */
diff -cbr orig/sh/c_ksh.c new/sh/c_ksh.c
*** orig/sh/c_ksh.c Sun May 03 18:45:02 1992
--- new/sh/c_ksh.c Tue Sep 08 11:39:17 1992
***************
*** 53,59 ****
v_pwd = global("PWD");
if ((pwd = strval(v_pwd)) == null) {
! setstr(v_pwd, getcwd(path, (size_t)PATH));
pwd = strval(v_pwd);
}
--- 53,60 ----
v_pwd = global("PWD");
if ((pwd = strval(v_pwd)) == null) {
! getcwd(path, (size_t)PATH);
! setstr(v_pwd, path);
pwd = strval(v_pwd);
}
***************
*** 78,85 ****
dir = strval(v_oldpwd = global("OLDPWD"));
prt = 1;
}
! if (dir[0] == '/' || (dir[0] == '.' && (dir[1] == '/' ||
! (dir[1] == '.' && dir[2] == '/')))) {
/*
* dir is an explicitly named path, so no CDPATH search
*/
--- 79,96 ----
dir = strval(v_oldpwd = global("OLDPWD"));
prt = 1;
}
! #ifdef OS2
! if (ISDIRSEP(dir[0]) ||
! (dir[0] == '.' &&
! (dir [1] == 0 || ISDIRSEP(dir[1]) ||
! (dir[1] == '.' && (dir[2] == 0 || ISDIRSEP(dir[2]))))) ||
! (isalpha(dir[0]) && dir[1] == ':') ) {
! #else
! if (ISDIRSEP(dir[0]) ||
! (dir[0] == '.' &&
! (dir[1] == 0 || ISDIRSEP(dir[1]) ||
! (dir[1] == '.' && (dir [2] == 0 || ISDIRSEP(dir[2])))))) {
! #endif
/*
* dir is an explicitly named path, so no CDPATH search
*/
***************
*** 96,102 ****
--- 107,117 ----
cdpath = strval(global("CDPATH"));
while ( !done && cdpath != NULL ) {
cp = path;
+ #ifdef OS2
+ while (*cdpath && *cdpath != ';')
+ #else
while (*cdpath && *cdpath != ':')
+ #endif
*cp++ = *cdpath++;
if (*cdpath == '\0')
cdpath = NULL;
***************
*** 103,109 ****
else
cdpath++;
if (prt = (cp > path)) {
! *cp++ = '/';
(void) strcpy( cp, dir );
cp = path;
} else
--- 118,124 ----
else
cdpath++;
if (prt = (cp > path)) {
! *cp++ = DIRSEP;
(void) strcpy( cp, dir );
cp = path;
} else
***************
*** 124,130 ****
--- 139,150 ----
* Keep track of OLDPWD and PWD
*/
oldpwd = pwd;
+ #ifdef OS2
+ getcwd(path, (size_t)PATH);
+ pwd = path;
+ #else
pwd = newd;
+ #endif
if (!v_oldpwd)
v_oldpwd = global("OLDPWD");
if (oldpwd && *oldpwd)
***************
*** 565,570 ****
--- 585,597 ----
return 0;
}
+
+ int
+ c_nothing(wp)
+ register char **wp;
+ {
+ return 0;
+ }
#endif
extern c_fc();
***************
*** 585,590 ****
--- 612,618 ----
{"fc", c_fc},
{"jobs", c_jobs},
{"kill", c_kill},
+ {"extproc", c_nothing},
#ifdef JOBS
{"fg", c_fgbg},
{"bg", c_fgbg},
diff -cbr orig/sh/c_sh.c new/sh/c_sh.c
*** orig/sh/c_sh.c Sun May 03 18:45:02 1992
--- new/sh/c_sh.c Sun Sep 06 20:08:01 1992
***************
*** 11,16 ****
--- 11,17 ----
#include <signal.h>
#include <setjmp.h>
#include <unistd.h> /* getcwd */
+ #include <time.h>
#include <sys/times.h>
#include "sh.h"
***************
*** 55,61 ****
if ((cp = wp[1]) == NULL) {
i = umask(0);
umask(i);
! printf("%#3.3o\n", i); /* should this be shell output? */
} else {
for (i = 0; *cp>='0' && *cp<='7'; cp++)
i = i*8 + (*cp-'0');
--- 56,62 ----
if ((cp = wp[1]) == NULL) {
i = umask(0);
umask(i);
! printf("%03o\n", i); /* should this be shell output? */
} else {
for (i = 0; *cp>='0' && *cp<='7'; cp++)
i = i*8 + (*cp-'0');
diff -cbr orig/sh/c_test.c new/sh/c_test.c
*** orig/sh/c_test.c Sun May 03 18:45:02 1992
--- new/sh/c_test.c Sun Sep 06 20:09:00 1992
***************
*** 279,285 ****
--- 279,289 ----
case FILCDEV:
return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFCHR;
case FILBDEV:
+ #ifdef S_IFBLK
return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFBLK;
+ #else
+ return 0;
+ #endif
case FILFIFO:
#ifdef S_IFIFO
return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFIFO;
***************
*** 287,297 ****
--- 291,313 ----
return 0;
#endif
case FILSETU:
+ #ifdef S_ISUID
return stat(nm, &s) == 0 && (s.st_mode & S_ISUID) == S_ISUID;
+ #else
+ return 0;
+ #endif
case FILSETG:
+ #ifdef S_ISGID
return stat(nm, &s) == 0 && (s.st_mode & S_ISGID) == S_ISGID;
+ #else
+ return 0;
+ #endif
case FILSTCK:
+ #ifdef S_ISVTX
return stat(nm, &s) == 0 && (s.st_mode & S_ISVTX) == S_ISVTX;
+ #else
+ return 0;
+ #endif
case FILGZ:
return stat(nm, &s) == 0 && s.st_size > 0L;
case FILTT:
diff -cbr orig/sh/config.h new/sh/config.h
*** orig/sh/config.h Tue Aug 25 15:21:05 1992
--- new/sh/config.h Sun Sep 06 19:28:14 1992
***************
*** 13,19 ****
#define EMACS /* EMACS-like mode */
#define VI /* vi-like mode */
! #define JOBS /* job control */
#ifndef SIGINT
#include <signal.h>
--- 13,19 ----
#define EMACS /* EMACS-like mode */
#define VI /* vi-like mode */
! /* #define JOBS /* job control */
#ifndef SIGINT
#include <signal.h>
***************
*** 30,36 ****
--- 30,39 ----
* or whatever does work. You may find it necessary to undef
* USE_SIGACT, if so please report it.
*/
+ #ifndef OS2
#define USE_SIGACT /* POSIX signal handling */
+ #endif
+
/*
* These control how sigact.c implements sigaction()
* If you don't define any of them it will try and work it out
***************
*** 46,52 ****
/* #define FASCIST /* Fascist getopts */
#define SHARPBANG /* Hack to handle #! */
! /* #define SILLY /* Game of life in EMACS mode */
/* #define SWTCH /* Handle SWTCH for shl(1) */
/*
--- 49,55 ----
/* #define FASCIST /* Fascist getopts */
#define SHARPBANG /* Hack to handle #! */
! #define SILLY /* Game of life in EMACS mode */
/* #define SWTCH /* Handle SWTCH for shl(1) */
/*
***************
*** 55,61 ****
* bind '^[^['=complete-list
* to their .kshrc
*/
! /*#define COMPLETE_LIST /* default to Emacs style completion */
/*
* ALTERNATIONS is csh not ksh, but it is such a nice feature...
*/
--- 58,64 ----
* bind '^[^['=complete-list
* to their .kshrc
*/
! #define COMPLETE_LIST /* default to Emacs style completion */
/*
* ALTERNATIONS is csh not ksh, but it is such a nice feature...
*/
diff -cbr orig/sh/edit.c new/sh/edit.c
*** orig/sh/edit.c Tue Aug 25 15:20:10 1992
--- new/sh/edit.c Tue Sep 01 08:22:29 1992
***************
*** 84,89 ****
--- 84,93 ----
int
x_getc()
{
+ #ifdef OS2
+ char c = _read_kbd(0, 1, 0);
+ return c == 0 ? 0xE0 : c;
+ #else
char c;
/*
***************
*** 103,108 ****
--- 107,113 ----
return -1;
}
return c & 0x7F;
+ #endif
}
void
***************
*** 343,348 ****
--- 348,372 ----
#else /* !_BSD */
+ #ifdef OS2
+
+ bool_t
+ x_mode(onoff)
+ bool_t onoff;
+ {
+ bool_t prev;
+ if (x_cur_mode == onoff)
+ return x_cur_mode;
+ prev = x_cur_mode;
+ x_cur_mode = onoff;
+
+ /* setkbdmode(onoff); */
+
+ return prev;
+ }
+
+ #else
+
bool_t
x_mode(onoff)
bool_t onoff;
***************
*** 396,401 ****
--- 420,426 ----
}
return prev;
}
+ #endif /* OS2 */
#endif /* _BSD */
***************
*** 427,432 ****
--- 452,462 ----
cp++;
count++;
}
+ else if ( *cp == '.' )
+ {
+ cp++;
+ count += strlen(strval(global("PWD")));
+ }
else
{
register int i = source->line;
diff -cbr orig/sh/emacs.c new/sh/emacs.c
*** orig/sh/emacs.c Tue Aug 25 15:20:11 1992
--- new/sh/emacs.c Tue Sep 01 09:04:22 1992
***************
*** 4,9 ****
--- 4,11 ----
* created by Ron Natalie at BRL
* modified by Doug Kingston, Doug Gwyn, and Lou Salkind
* adapted to PD ksh by Eric Gisin
+ * Modified Sep 1991 by Kai Uwe Rommel for OS/2:
+ * 8 bit support, 3rd meta key (extended keys)
*/
#include "config.h"
***************
*** 16,21 ****
--- 18,28 ----
#include "stdh.h"
#include <signal.h>
#include <sys/stat.h>
+ #ifdef OS2
+ #include <memory.h>
+ extern char *index_sep(char *);
+ extern char *rindex_sep(char *);
+ #endif
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
***************
*** 64,79 ****
#define iscfs(c) (c == ' ' || c == '\t') /* Separator for completion */
#define ismfs(c) (!(isalnum(c)|| c == '$')) /* Separator for motion */
#define BEL 0x07
! #define CMASK 0x7F /* 7-bit ASCII character mask */
! #define X_TABSZ 128 /* size of keydef tables etc */
static int x_prefix1 = CTRL('['), x_prefix2 = CTRL('X');
static char **x_histp; /* history position */
static char **x_nextcmdp; /* for newline-and-next */
static char *xmp; /* mark pointer */
static int (*x_last_command)();
! static struct x_ftab const *(*x_tab)[X_TABSZ] = NULL; /* key definition */
static char *(*x_atab)[X_TABSZ] = NULL; /* macro definitions */
#define KILLSIZE 20
static char *killstack[KILLSIZE];
--- 71,88 ----
#define iscfs(c) (c == ' ' || c == '\t') /* Separator for completion */
#define ismfs(c) (!(isalnum(c)|| c == '$')) /* Separator for motion */
#define BEL 0x07
! #define CMASK 0xFF /* 7-bit ASCII character mask */
! #define X_TABS 4 /* number of keydef tables etc */
! #define X_TABSZ 256 /* size of keydef tables etc */
static int x_prefix1 = CTRL('['), x_prefix2 = CTRL('X');
+ static int x_prefix3 = 0xE0;
static char **x_histp; /* history position */
static char **x_nextcmdp; /* for newline-and-next */
static char *xmp; /* mark pointer */
static int (*x_last_command)();
! static struct x_ftab *(*x_tab)[X_TABSZ] = NULL; /* key definition */
static char *(*x_atab)[X_TABSZ] = NULL; /* macro definitions */
#define KILLSIZE 20
static char *killstack[KILLSIZE];
***************
*** 123,128 ****
--- 132,138 ----
static int x_literal ARGS((int c));
static int x_meta1 ARGS((int c));
static int x_meta2 ARGS((int c));
+ static int x_meta3 ARGS((int c));
static int x_kill ARGS((int c));
static void x_push ARGS((int nchars));
static int x_yank ARGS((int c));
***************
*** 158,165 ****
static int x_set_arg ARGS((int c));
static int x_prev_histword ARGS((void));
static int x_fold_case ARGS((int c));
! static struct x_ftab const x_ftab[] = {
{x_insert, "auto-insert", 0, 0, 0 },
{x_error, "error", 0, 0, 0 },
{x_ins_string, "macro-string", 0, 0, XF_NOBIND|XF_ALLOC},
--- 168,178 ----
static int x_set_arg ARGS((int c));
static int x_prev_histword ARGS((void));
static int x_fold_case ARGS((int c));
+ static int x_clear_scr ARGS((int c));
+ static int x_list_jobs ARGS((int c));
+
! static struct x_ftab x_ftab[] = {
{x_insert, "auto-insert", 0, 0, 0 },
{x_error, "error", 0, 0, 0 },
{x_ins_string, "macro-string", 0, 0, XF_NOBIND|XF_ALLOC},
***************
*** 167,173 ****
{x_eot_del, "eot-or-delete", 0, CTRL('D'), 0 },
{x_del_bword, "delete-word-backward", 1, CTRL('H'), 0 },
{x_mv_bword, "backward-word", 1, 'b', 0 },
! {x_del_line, "kill-line", 0, 0, 0 },
{x_abort, "abort", 0, 0, 0 },
{x_noop, "no-op", 0, 0, 0 },
/* Do not move the above! */
--- 180,186 ----
{x_eot_del, "eot-or-delete", 0, CTRL('D'), 0 },
{x_del_bword, "delete-word-backward", 1, CTRL('H'), 0 },
{x_mv_bword, "backward-word", 1, 'b', 0 },
! {x_del_line, "kill-line", 0, CTRL('U'), 0 },
{x_abort, "abort", 0, 0, 0 },
{x_noop, "no-op", 0, 0, 0 },
/* Do not move the above! */
***************
*** 188,196 ****
{x_end_hist, "end-of-history", 1, '>', 0},
{x_mv_end, "end-of-line", 0, CTRL('E'), 0 },
{x_mv_begin, "beginning-of-line", 0, CTRL('A'), 0 },
! {x_draw_line, "redraw", 0, CTRL('L'), 0 },
{x_meta1, "prefix-1", 0, CTRL('['), 0 },
{x_meta2, "prefix-2", 0, CTRL('X'), 0 },
{x_kill, "kill-to-eol", 0, CTRL('K'), 0 },
{x_yank, "yank", 0, CTRL('Y'), 0 },
{x_meta_yank, "yank-pop", 1, 'y', 0 },
--- 201,211 ----
{x_end_hist, "end-of-history", 1, '>', 0},
{x_mv_end, "end-of-line", 0, CTRL('E'), 0 },
{x_mv_begin, "beginning-of-line", 0, CTRL('A'), 0 },
! {x_draw_line, "redraw", 0, 0, 0 },
! {x_clear_scr, "clear-screen", 0, CTRL('L'), 0 },
{x_meta1, "prefix-1", 0, CTRL('['), 0 },
{x_meta2, "prefix-2", 0, CTRL('X'), 0 },
+ {x_meta3, "prefix-3", 0, 0xE0, 0 },
{x_kill, "kill-to-eol", 0, CTRL('K'), 0 },
{x_yank, "yank", 0, CTRL('Y'), 0 },
{x_meta_yank, "yank-pop", 1, 'y', 0 },
***************
*** 213,220 ****
{x_enumerate, "list", 1, '?', 0 },
{x_comp_file, "complete-file", 1, CTRL('X'), 0 },
{x_comp_comm, "complete-command", 2, CTRL('['), 0 },
! {x_list_file, "list-file", 0, 0, 0 },
{x_list_comm, "list-command", 2, '?', 0 },
{x_nl_next_com, "newline-and-next", 0, CTRL('O'), 0 },
{x_set_mark, "set-mark-command", 1, ' ', 0 },
{x_kill_region, "kill-region", 0, CTRL('W'), 0 },
--- 228,236 ----
{x_enumerate, "list", 1, '?', 0 },
{x_comp_file, "complete-file", 1, CTRL('X'), 0 },
{x_comp_comm, "complete-command", 2, CTRL('['), 0 },
! {x_list_file, "list-file", 2, CTRL('Y'), 0 },
{x_list_comm, "list-command", 2, '?', 0 },
+ {x_list_jobs, "list-jobs", 2, 'j', 0 },
{x_nl_next_com, "newline-and-next", 0, CTRL('O'), 0 },
{x_set_mark, "set-mark-command", 1, ' ', 0 },
{x_kill_region, "kill-region", 0, CTRL('W'), 0 },
***************
*** 263,269 ****
char *buf;
size_t len;
{
! char c;
int i;
int (*func)();
extern x_insert();
--- 279,285 ----
char *buf;
size_t len;
{
! int c;
int i;
int (*func)();
extern x_insert();
***************
*** 832,837 ****
--- 848,854 ----
xlp_valid = TRUE;
*xcp = 0;
xmp = NULL;
+ if ( c != -1 )
x_redraw(j);
return KSTD;
}
***************
*** 961,966 ****
--- 978,989 ----
}
static int
+ x_meta3(c) {
+ x_curprefix = 3;
+ return KPREF;
+ }
+
+ static int
x_kill(c) {
int i;
***************
*** 1028,1033 ****
--- 1051,1057 ----
xlp = xep = xcp = xbp = xbuf;
xlp_valid = TRUE;
*xcp = 0;
+ x_del_line(-1);
return KINTR;
}
***************
*** 1078,1084 ****
/* XXX -- should handle \^ escape? */
if (*cp == '^') {
cp++;
! if (*cp >= '?') /* includes '?'; ASCII */
*op++ = CTRL(*cp);
else {
*op++ = '^';
--- 1102,1110 ----
/* XXX -- should handle \^ escape? */
if (*cp == '^') {
cp++;
! if (*cp == '0')
! *op++ = 0xE0;
! else if (*cp >= '?') /* includes '?'; ASCII */
*op++ = CTRL(*cp);
else {
*op++ = '^';
***************
*** 1101,1106 ****
--- 1127,1136 ----
if (c < ' ' || c == 0x7F) { /* ASCII */
*p++ = '^';
*p++ = (c == 0x7F) ? '?' : (c | 0x40);
+ }
+ else if (c == 0xE0) {
+ *p++ = '^';
+ *p++ = '0';
} else
*p++ = c;
*p = 0;
***************
*** 1115,1120 ****
--- 1145,1152 ----
shellf("%s", x_mapout(x_prefix1));
if (prefix == 2)
shellf("%s", x_mapout(x_prefix2));
+ if (prefix == 3)
+ shellf("%s", x_mapout(x_prefix3));
shellf("%s = ", x_mapout(key));
if (x_tab[prefix][key]->xf_func != x_ins_string)
shellf("%s\n", x_tab[prefix][key]->xf_name);
***************
*** 1127,1142 ****
char *a1, *a2;
int macro; /* bind -m */
{
! struct x_ftab const *fp;
int prefix, key;
char *sp = NULL;
if (x_tab == NULL)
! errorf("cannot bind, not a tty\n");
if (a1 == NULL) {
! for (prefix = 0; prefix < 3; prefix++)
! for (key = 0; key < 0x80; key++) {
fp = x_tab[prefix][key];
if (fp == NULL ||
fp->xf_func == x_insert || fp->xf_func == x_error)
--- 1159,1175 ----
char *a1, *a2;
int macro; /* bind -m */
{
! struct x_ftab *fp;
int prefix, key;
char *sp = NULL;
if (x_tab == NULL)
! return;
! /* errorf("cannot bind, not a tty\n"); */
if (a1 == NULL) {
! for (prefix = 0; prefix < X_TABS; prefix++)
! for (key = 0; key < X_TABSZ; key++) {
fp = x_tab[prefix][key];
if (fp == NULL ||
fp->xf_func == x_insert || fp->xf_func == x_error)
***************
*** 1156,1161 ****
--- 1189,1197 ----
if (x_tab[prefix][key]->xf_func == x_meta2)
prefix = 2;
else
+ if (x_tab[prefix][key]->xf_func == x_meta3)
+ prefix = 3;
+ else
break;
}
***************
*** 1176,1181 ****
--- 1212,1219 ----
x_prefix1 = key;
if (fp->xf_func == x_meta2)
x_prefix2 = key;
+ if (fp->xf_func == x_meta3)
+ x_prefix3 = key;
} else {
fp = xft_ins_string;
x_mapin(a2);
***************
*** 1192,1217 ****
x_init_emacs()
{
register int i, j;
! struct x_ftab const *fp;
ainit(AEDIT);
! x_tab = (struct x_ftab *(*)[X_TABSZ]) alloc(sizeofN(*x_tab, 3), AEDIT);
! for (j = 0; j < 128; j++)
x_tab[0][j] = xft_insert;
! for (i = 1; i < 3; i++)
! for (j = 0; j < 128; j++)
x_tab[i][j] = xft_error;
for (fp = x_ftab; fp->xf_func; fp++)
if (fp->xf_db_char || fp->xf_db_tab)
x_tab[fp->xf_db_tab][fp->xf_db_char] = fp;
! x_atab = (char *(*)[X_TABSZ]) alloc(sizeofN(*x_atab, 3), AEDIT);
! for (i = 1; i < 3; i++)
! for (j = 0; j < 128; j++)
x_atab[i][j] = NULL;
}
void
x_emacs_keys(erase, kill, werase, intr, quit)
int erase, kill, werase, intr, quit;
--- 1230,1263 ----
x_init_emacs()
{
register int i, j;
! struct x_ftab *fp;
ainit(AEDIT);
! x_tab = (struct x_ftab *(*)[X_TABSZ]) alloc(sizeofN(*x_tab, X_TABS), AEDIT);
! for (j = 0; j < X_TABSZ; j++)
x_tab[0][j] = xft_insert;
! for (i = 1; i < X_TABS; i++)
! for (j = 0; j < X_TABSZ; j++)
x_tab[i][j] = xft_error;
for (fp = x_ftab; fp->xf_func; fp++)
if (fp->xf_db_char || fp->xf_db_tab)
x_tab[fp->xf_db_tab][fp->xf_db_char] = fp;
! x_atab = (char *(*)[X_TABSZ]) alloc(sizeofN(*x_atab, X_TABS), AEDIT);
! for (i = 1; i < X_TABS; i++)
! for (j = 0; j < X_TABSZ; j++)
x_atab[i][j] = NULL;
}
+ static int
+ x_clear_scr(c)
+ {
+ write(1, "\033[H\033[J", 6);
+ x_redraw(0);
+ return KSTD;
+ }
+
void
x_emacs_keys(erase, kill, werase, intr, quit)
int erase, kill, werase, intr, quit;
***************
*** 1357,1371 ****
if (strcmp(dirnam, ".") == 0)
*buf = '\0';
! else if (strcmp(dirnam, "/") == 0)
! (void)strcpy(buf, "/");
else
! (void)strcat(strcpy(buf, dirnam), "/");
(void)strcat(buf, name);
if (stat(buf, &statb)==0)
if (S_ISDIR(statb.st_mode))
type = '/';
! else if (S_ISREG(statb.st_mode) && access(buf, 01)==0)
type = '*';
if (type)
++len;
--- 1403,1418 ----
if (strcmp(dirnam, ".") == 0)
*buf = '\0';
! else if (strcmp(dirnam, DIRSEPSTR) == 0)
! (void)strcpy(buf, DIRSEPSTR);
else
! (void)strcat(strcpy(buf, dirnam), DIRSEPSTR);
(void)strcat(buf, name);
if (stat(buf, &statb)==0)
if (S_ISDIR(statb.st_mode))
type = '/';
! else if (S_ISREG(statb.st_mode) &&
! (statb.st_mode & S_IEXEC) != 0)
type = '*';
if (type)
++len;
***************
*** 1451,1456 ****
--- 1498,1512 ----
compl_file(0);
return KSTD;
}
+
+ static int
+ x_list_jobs(c)
+ int c;
+ {
+ j_jobs();
+ x_redraw(-1);
+ return KSTD;
+ }
static int
x_comp_list(c) {
compl_dec(2);
***************
*** 1460,1466 ****
static void compl_dec(type) { char *cp; cp = xcp;
while (cp != xbuf && !iscfs(*cp))
cp--;
! if (cp == xbuf && strchr(cp, '/') == NULL)
compl_command(type);
else
compl_file(type);
--- 1516,1522 ----
static void compl_dec(type) { char *cp; cp = xcp;
while (cp != xbuf && !iscfs(*cp))
cp--;
! if (cp == xbuf && index_sep(cp) == NULL)
compl_command(type);
else
compl_file(type);
***************
*** 1510,1520 ****
*cp = 0;
strcpy(buf, cp = substitute(buf, DOTILDE));
afree((void*)cp, ATEMP);
! lastp = strrchr(buf, '/');
if (lastp)
*lastp = 0;
! dirnam = (lastp == NULL) ? "." : (lastp == buf) ? "/" : buf;
dirp = opendir(dirnam);
if (dirp == NULL) {
x_putc(BEL);
--- 1566,1576 ----
*cp = 0;
strcpy(buf, cp = substitute(buf, DOTILDE));
afree((void*)cp, ATEMP);
! lastp = rindex_sep(buf);
if (lastp)
*lastp = 0;
! dirnam = (lastp == NULL) ? "." : (lastp == buf) ? DIRSEPSTR : buf;
dirp = opendir(dirnam);
if (dirp == NULL) {
x_putc(BEL);
***************
*** 1564,1575 ****
buf[0] = 0;
else if (lastp == buf + 1) {
buf[1] = 0;
! buf[0] = '/';
} else
! (void)strcat(buf, "/");
(void)strcat(buf, bug);
if (stat(buf, &statb) == 0 && S_ISDIR(statb.st_mode))
! x_ins("/");
else
x_ins(" ");
}
--- 1620,1632 ----
buf[0] = 0;
else if (lastp == buf + 1) {
buf[1] = 0;
! buf[0] = DIRSEP;
} else
! (void)strcat(buf, DIRSEPSTR);
(void)strcat(buf, bug);
if (stat(buf, &statb) == 0 && S_ISDIR(statb.st_mode))
! x_ins("/" /* DIRSEPSTR */);
! /* conflict with \ at end of line in OS/2 mode ! */
else
x_ins(" ");
}
***************
*** 1726,1732 ****
if (hp < history || hp > histptr)
{
x_putc(BEL);
! return;
}
cp = *hp;
if (x_last_command != x_set_arg)
--- 1783,1789 ----
if (hp < history || hp > histptr)
{
x_putc(BEL);
! return KSTD;
}
cp = *hp;
if (x_last_command != x_set_arg)
diff -cbr orig/sh/eval.c new/sh/eval.c
*** orig/sh/eval.c Tue Aug 25 15:21:05 1992
--- new/sh/eval.c Sun Sep 06 20:11:15 1992
***************
*** 9,14 ****
--- 9,18 ----
#include "stdh.h"
#include <errno.h>
#include <setjmp.h>
+ #ifdef OS2
+ #include <sys/types.h>
+ #include <stdlib.h>
+ #endif
#include <unistd.h>
#include <dirent.h>
#include <pwd.h>
***************
*** 789,798 ****
}
if (dp > ds)
! *dp++ = '/';
! while (*sp == '/')
*dp++ = *sp++;
! np = strchr(sp, '/');
if (np != NULL)
*np++ = 0;
--- 793,802 ----
}
if (dp > ds)
! *dp++ = DIRSEP;
! while (ISDIRSEP(*sp))
*dp++ = *sp++;
! np = index_sep(sp);
if (np != NULL)
*np++ = 0;
***************
*** 833,839 ****
}
if (np != NULL)
! *--np = '/';
}
/* remove MAGIC from string */
--- 837,843 ----
}
if (np != NULL)
! *--np = DIRSEP;
}
/* remove MAGIC from string */
***************
*** 880,890 ****
}
dp = NULL; /* no output substitution */
! if (cp[1] == 0 || cp[1] == '/' || cp[1] == ':') /* ~ or ~/ */
dp = strval(global("HOME")), cp += 1;
! else if (cp[1] == '+' && (cp[2] == '/' || cp[2] == ':' || cp[2] == 0))
dp = strval(global("PWD")), cp += 2;
! else if (cp[1] == '-' && (cp[2] == '/' || cp[2] == ':' || cp[2] == 0))
dp = strval(global("OLDPWD")), cp += 2;
else if (letter(cp[1])) {
char *save = cp;
--- 884,894 ----
}
dp = NULL; /* no output substitution */
! if (cp[1] == 0 || ISDIRSEP(cp[1]) || cp[1] == ':') /* ~ or ~/ */
dp = strval(global("HOME")), cp += 1;
! else if (cp[1] == '+' && (ISDIRSEP(cp[2]) || cp[2] == ':' || cp[2] == 0))
dp = strval(global("PWD")), cp += 2;
! else if (cp[1] == '-' && (ISDIRSEP(cp[2]) || cp[2] == ':' || cp[2] == 0))
dp = strval(global("OLDPWD")), cp += 2;
else if (letter(cp[1])) {
char *save = cp;
***************
*** 914,919 ****
--- 918,926 ----
homedir(name)
char *name;
{
+ #ifdef OS2
+ return getenv("HOME");
+ #else
register struct tbl *ap;
register struct passwd *pw;
extern struct passwd *getpwnam();
***************
*** 925,928 ****
--- 932,936 ----
if (pw == NULL)
return NULL;
return pw->pw_dir;
+ #endif
}
diff -cbr orig/sh/exec.c new/sh/exec.c
*** orig/sh/exec.c Tue Aug 25 15:20:12 1992
--- new/sh/exec.c Mon Sep 21 10:35:07 1992
***************
*** 10,15 ****
--- 10,18 ----
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
+ #ifdef OS2
+ #include <process.h>
+ #endif
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
***************
*** 241,247 ****
clexec_tab[i] = 0;
}
#endif
! execve(t->str, t->args, ap);
if (errno == ENOEXEC) {
char *shell;
#ifdef SHARPBANG
--- 244,250 ----
clexec_tab[i] = 0;
}
#endif
! _execve(t->str, t->args, ap);
if (errno == ENOEXEC) {
char *shell;
#ifdef SHARPBANG
***************
*** 256,263 ****
}
*t->args-- = t->str;
*t->args = shell;
! execve(t->args[0], t->args, ap);
! errorf("No shell\n");
#endif /* SHARPBANG */
}
errorf("%s: %s\n", s, strerror(errno));
--- 259,266 ----
}
*t->args-- = t->str;
*t->args = shell;
! _execve(t->args[0], t->args, ap);
! errorf("Cannot execute.\n");
#endif /* SHARPBANG */
}
errorf("%s: %s\n", s, strerror(errno));
***************
*** 264,270 ****
}
quitenv(); /* restores IO */
! if (e.interactive) { /* flush stdout, shlout */
fflush(shf[1]);
fflush(shf[2]);
}
--- 267,273 ----
}
quitenv(); /* restores IO */
! if (e.interactive) { /* fflush stdout, shlout */
fflush(shf[1]);
fflush(shf[2]);
}
***************
*** 425,431 ****
register int fd, n;
char *shell;
! shell = strval(global("EXECSHELL"));
if (shell && *shell) {
if ((shell = search(shell,path,1)) == NULL)
shell = SHELL;
--- 428,434 ----
register int fd, n;
char *shell;
! shell = strval(global("COMSPEC"));
if (shell && *shell) {
if ((shell = search(shell,path,1)) == NULL)
shell = SHELL;
***************
*** 440,447 ****
line[n] = '\0';
(void) close(fd);
}
! if (line[0] == '#' && line[1] == '!') {
! cp = &line[2];
while (*cp && (*cp == ' ' || *cp == '\t'))
cp++;
if (*cp && *cp != '\n') {
--- 443,451 ----
line[n] = '\0';
(void) close(fd);
}
! if ((line[0] == '#' && line[1] == '!') ||
! strnicmp(line, "extproc", 7) == 0) {
! cp = line + (line[0] == '#' ? 2 : 7);
while (*cp && (*cp == ' ' || *cp == '\t'))
cp++;
if (*cp && *cp != '\n') {
***************
*** 462,474 ****
}
}
*cp = '\0';
! } else
*tp->args = shell;
! } else
*tp->args = shell;
! (void) execve(tp->args[0], tp->args, ap);
! errorf( "No shell\n" );
}
#endif /* SHARPBANG */
--- 466,482 ----
}
}
*cp = '\0';
! } else {
! *tp->args-- = "/c";
*tp->args = shell;
! }
! } else {
! *tp->args-- = "/c";
*tp->args = shell;
+ }
! (void) _execve(tp->args[0], tp->args, ap);
! errorf( "Cannot execute.\n" );
}
#endif /* SHARPBANG */
***************
*** 557,563 ****
register struct tbl *tp = NULL;
static struct tbl temp;
! if (strchr(name, '/') != NULL) {
tp = &temp;
tp->type = CEXEC;
tp->flag = 0; /* make ~ISSET */
--- 565,571 ----
register struct tbl *tp = NULL;
static struct tbl temp;
! if (index_sep(name) != NULL) {
tp = &temp;
tp->type = CEXEC;
tp->flag = 0; /* make ~ISSET */
***************
*** 610,616 ****
register struct tbl *tp;
for (twalk(&commands); (tp = tnext()) != NULL; )
! if ((tp->flag&ISSET) && (all || tp->val.s[0] != '/')) {
if ((tp->flag&ALLOC))
afree(tp->val.s, commands.areap);
tp->flag = DEFINED; /* make ~ISSET */
--- 618,624 ----
register struct tbl *tp;
for (twalk(&commands); (tp = tnext()) != NULL; )
! if ((tp->flag&ISSET) && (all || !ISDIRSEP(tp->val.s[0]))) {
if ((tp->flag&ALLOC))
afree(tp->val.s, commands.areap);
tp->flag = DEFINED; /* make ~ISSET */
***************
*** 617,622 ****
--- 625,671 ----
}
}
+ #ifdef OS2
+
+ int eaccess2(char *path, int mode)
+ {
+ struct stat s;
+ int i = access(path, mode);
+
+ if (i == 0 && mode == 1 && stat(path,&s) == 0 &&
+ ((s.st_mode & S_IFMT) != S_IFREG || (s.st_mode & S_IEXEC) == 0))
+ return -1;
+ else
+ return i;
+ }
+
+ int eaccess1(char *path, int mode)
+ {
+ char *tp = path + strlen(path);
+ int i;
+
+ if ( i = eaccess2(path, mode) )
+ {
+ strcpy(tp, ".exe");
+ if ( i = eaccess2(path, mode) )
+ {
+ strcpy(tp, ".com");
+ if ( i = eaccess2(path, mode) )
+ {
+ strcpy(tp, ".ksh");
+ if ( i = access(path, 0) )
+ {
+ strcpy(tp, ".cmd");
+ if ( i = eaccess2(path, mode) )
+ *tp = 0;
+ }
+ }
+ }
+ }
+ return i;
+ }
+ #endif
+
/*
* search for command with PATH
*/
***************
*** 628,650 ****
register int i;
register char *sp, *tp;
struct stat buf;
! if (strchr(name, '/'))
return (eaccess(name, mode) == 0) ? name : NULL;
sp = path;
while (sp != NULL) {
tp = line;
for (; *sp != '\0'; tp++)
if ((*tp = *sp++) == ':') {
--sp;
break;
}
if (tp != line)
! *tp++ = '/';
for (i = 0; (*tp++ = name[i++]) != '\0';)
;
! i = eaccess(line, mode);
if (i == 0 && (mode != 1 || (stat(line,&buf) == 0 &&
(buf.st_mode & S_IFMT) == S_IFREG)))
return line;
--- 677,714 ----
register int i;
register char *sp, *tp;
struct stat buf;
+ #ifdef OS2
+ static char real[LINE + 1];
+
+ strcpy(line, name);
+
+ if (eaccess1(line, mode) == 0)
+ return line;
! if (index_sep(name))
! return (eaccess1(line, mode) == 0) ? line : NULL;
! #else
! if (index_sep(name))
return (eaccess(name, mode) == 0) ? name : NULL;
+ #endif
sp = path;
while (sp != NULL) {
tp = line;
for (; *sp != '\0'; tp++)
+ #ifdef OS2
+ if ((*tp = *sp++) == ';') {
+ #else
if ((*tp = *sp++) == ':') {
+ #endif
--sp;
break;
}
if (tp != line)
! *tp++ = DIRSEP;
for (i = 0; (*tp++ = name[i++]) != '\0';)
;
! i = eaccess1(line, mode);
if (i == 0 && (mode != 1 || (stat(line,&buf) == 0 &&
(buf.st_mode & S_IFMT) == S_IFREG)))
return line;
***************
*** 790,795 ****
--- 854,860 ----
while (*ap != NULL)
shellf(" %s", *ap++);
shellf("\n");
+ fflush(shlout);
}
/*
diff -cbr orig/sh/expr.c new/sh/expr.c
*** orig/sh/expr.c Sun May 03 18:45:06 1992
--- new/sh/expr.c Sun May 03 19:41:24 1992
***************
*** 20,27 ****
#define LLE 0x05
#define LGE 0x06
! static const char *expression; /* expression being evaluated */
! static const char *tokp; /* lexical position */
static int tok; /* token from token() */
static struct tbl *val; /* value from token() */
--- 20,27 ----
#define LLE 0x05
#define LGE 0x06
! static char *expression; /* expression being evaluated */
! static char *tokp; /* lexical position */
static int tok; /* token from token() */
static struct tbl *val; /* value from token() */
***************
*** 51,57 ****
{
struct tbl *v;
! expression = tokp = expr;
token();
v = intvar(asn());
if (!(tok == 0))
--- 51,57 ----
{
struct tbl *v;
! expression = tokp = (char *) expr;
token();
v = intvar(asn());
if (!(tok == 0))
diff -cbr orig/sh/history.c new/sh/history.c
*** orig/sh/history.c Tue Aug 25 15:21:06 1992
--- new/sh/history.c Sun Sep 06 20:14:20 1992
***************
*** 18,23 ****
--- 18,31 ----
* to work on your system
*/
+ #ifndef HISTFILE
+ # ifdef OS2
+ # define HISTFILE "history.ksh"
+ # else
+ # define HISTFILE ".pdksh_hist"
+ # endif
+ #endif
+
#include "config.h"
#include "stdh.h"
***************
*** 29,37 ****
static FILE *hist_fh = NULL;
static FILE *hist_open ARGS((char *mode));
- #ifndef HISTFILE
- # define HISTFILE ".pdksh_hist"
- #endif
#else
/* Defines and includes for the complicated case */
--- 37,42 ----
diff -cbr orig/sh/io.c new/sh/io.c
*** orig/sh/io.c Tue Aug 25 15:20:17 1992
--- new/sh/io.c Tue Sep 08 12:36:07 1992
***************
*** 99,104 ****
--- 99,107 ----
if (shf[fd] != NULL)
return;
if (fd <= 2)
+ #ifdef __EMX__
+ /* ??? _streamv[fd].flags = 0; /* re-use stdin, stdout, stderr */
+ #else
#ifndef _BSDI
#ifdef _MINIX
/* ? */;
***************
*** 109,114 ****
--- 112,118 ----
/* Chris Torek's stdio replacement */
__sF[fd]._flags = 0;
#endif
+ #endif
shf[fd] = fdopen(fd, "r+");
if (shf[fd] == NULL)
return;
***************
*** 141,147 ****
--- 145,155 ----
if (fd < FDBASE) {
flushshf(fd);
+ #ifdef OS2
+ nfd = getdup(fd, FDBASE);
+ #else
nfd = fcntl(fd, F_DUPFD, FDBASE);
+ #endif
if (nfd < 0)
if (errno == EBADF)
return -1;
***************
*** 150,156 ****
#ifdef F_SETFD
(void) fcntl(nfd, F_SETFD, 1);
#else
! (void) fd_clexec(ttyfd);
#endif
close(fd);
} else
--- 158,164 ----
#ifdef F_SETFD
(void) fcntl(nfd, F_SETFD, 1);
#else
! (void) fd_clexec(nfd);
#endif
close(fd);
} else
***************
*** 168,174 ****
--- 176,186 ----
close(fd);
if (ofd < 0) /* original fd closed */
return;
+ #ifdef OS2
+ dup2(ofd, fd);
+ #else
(void) fcntl(ofd, F_DUPFD, fd);
+ #endif
close(ofd);
}
***************
*** 202,210 ****
--- 214,229 ----
static unsigned int inc = 0;
char path [PATH];
+ #ifdef OS2
+ extern char *getenv();
+ char *tmp = getenv("TMP");
+ sprintf(path, "%s/shXXXXXX", tmp ? tmp : "");
+ mktemp(path);
+ #else
sprintf(path, "/tmp/sh%05u%02u", (unsigned)getpid(), inc++);
#if defined(_SYSV) || defined(_BSD)
close(creat(path, 0600)); /* to get appropriate permissions */
+ #endif
#endif
tp = (struct temp *) alloc(sizeof(struct temp), ap);
tp->next = NULL;
diff -cbr orig/sh/jobs.c new/sh/jobs.c
*** orig/sh/jobs.c Tue Aug 25 15:20:17 1992
--- new/sh/jobs.c Sun Sep 06 20:16:02 1992
***************
*** 18,28 ****
#include "stdh.h"
#include <errno.h>
- #include <unistd.h>
#include <signal.h>
#include <setjmp.h>
#include <sys/times.h>
#include <sys/wait.h>
#include "sh.h"
#ifdef JOBS
#ifdef _BSDI
--- 18,35 ----
#include "stdh.h"
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
+ #ifdef OS2
+ #include <time.h>
+ #include <process.h>
+ typedef int pid_t;
+ #endif
+ #include <unistd.h>
#include <sys/times.h>
+ #ifndef OS2
#include <sys/wait.h>
+ #endif
#include "sh.h"
#ifdef JOBS
#ifdef _BSDI
***************
*** 32,40 ****
--- 39,49 ----
#ifdef _BSD
#include <sys/ioctl.h>
#else
+ #ifndef OS2
#include "termios.h"
#endif
#endif
+ #endif
#ifdef _BSD
/*
***************
*** 68,76 ****
--- 77,103 ----
# define waitpid(pid, sp, opts) wait3(sp, opts, (void*)NULL)
# endif
#else /* not _BSD */
+ # ifndef WIFSTOPPED
+ # define WIFSTOPPED(x) (((x)&0xFF) == 0x7F)
+ # endif
+ # ifndef WIFSIGNALED
+ # define WIFSIGNALED(x) (((x)&0xFF) != 0x7F && ((x)&0x7F) != 0)
+ # endif
+ # ifndef WIFEXITED
+ # define WIFEXITED(x) (((x)&0xFF) != 0x7F && ((x)&0x7F) == 0)
+ # endif
# ifndef WIFCORED
# define WIFCORED(x) (!!((x)&0x80)) /* non-standard */
# endif
+ # ifndef WEXITSTATUS
+ # define WEXITSTATUS(x) ((x)>>8&0xFF)
+ # endif
+ # ifndef WTERMSIG
+ # define WTERMSIG(x) ((x)&0x7F)
+ # endif
+ # ifndef WSTOPSIG
+ # define WSTOPSIG(x) ((x)>>8&0xFF)
+ # endif
#endif
/* as of P1003.1 Draft 12.3:
***************
*** 325,331 ****
#ifdef JOBS
/* don't allow SIGCHLD until we are ready */
! #ifdef USE_SIGACT
sigprocmask(SIG_SETMASK, &sm_sigchld, NULL);
# else
sigsetmask(sm_sigchld);
--- 352,358 ----
#ifdef JOBS
/* don't allow SIGCHLD until we are ready */
! # ifdef USE_SIGACT
sigprocmask(SIG_SETMASK, &sm_sigchld, NULL);
# else
sigsetmask(sm_sigchld);
diff -cbr orig/sh/lex.c new/sh/lex.c
*** orig/sh/lex.c Tue Aug 25 15:20:17 1992
--- new/sh/lex.c Tue Sep 01 08:41:20 1992
***************
*** 9,15 ****
--- 9,17 ----
#include "stdh.h"
#include <errno.h>
#include <setjmp.h>
+ #ifndef OS2
#include <unistd.h>
+ #endif
#include <assert.h>
#include "sh.h"
#include "expand.h"
***************
*** 78,84 ****
if (c == '#')
while ((c = getsc()) != 0 && c != '\n')
;
! ungetsc();
}
if (alias) { /* trailing ' ' in alias definition */
alias = 0;
--- 80,86 ----
if (c == '#')
while ((c = getsc()) != 0 && c != '\n')
;
! if (c) ungetsc();
}
if (alias) { /* trailing ' ' in alias definition */
alias = 0;
***************
*** 95,103 ****
switch (c) {
case '\\':
c = getsc();
! if (c != '\n')
*wp++ = QCHAR, *wp++ = c;
! else
if (wp == Xstring(ws, wp))
goto Again;
break;
--- 97,111 ----
switch (c) {
case '\\':
c = getsc();
! if (c != '\n') {
! #ifdef OS2
! if ( isalnum(c) ) {
! *wp++ = CHAR, *wp++ = '\\';
! *wp++ = CHAR, *wp++ = c;
! } else
! #endif
*wp++ = QCHAR, *wp++ = c;
! } else
if (wp == Xstring(ws, wp))
goto Again;
break;
***************
*** 647,652 ****
--- 655,661 ----
pprompt(cp)
register char *cp;
{
+ putc('\r', shlout);
while (*cp != 0)
if (*cp != '!')
putc(*cp++, shlout);
***************
*** 654,659 ****
--- 663,674 ----
if (*++cp == '!')
putc(*cp++, shlout);
else
+ if (*cp == '.')
+ {
+ shellf("%s", strval(global("PWD")));
+ cp++;
+ }
+ else
shellf("%d", source->line);
fflush(shlout);
}
diff -cbr orig/sh/mail.c new/sh/mail.c
*** orig/sh/mail.c Sun May 03 18:45:09 1992
--- new/sh/mail.c Tue Sep 01 09:14:16 1992
***************
*** 120,126 ****
mval = strsave(mptoparse, APERM);
while (mval) {
mpath = mval;
! if ((mval = strchr(mval, ':')) != NULL) {
*mval ='\0', mval++;
}
if ((mmsg = strchr(mpath, '?')) != NULL) {
--- 120,126 ----
mval = strsave(mptoparse, APERM);
while (mval) {
mpath = mval;
! if ((mval = strchr(mval, PATHSEP)) != NULL) {
*mval ='\0', mval++;
}
if ((mmsg = strchr(mpath, '?')) != NULL) {
diff -cbr orig/sh/main.c new/sh/main.c
*** orig/sh/main.c Tue Aug 25 15:21:06 1992
--- new/sh/main.c Sat Sep 26 13:07:12 1992
***************
*** 9,15 ****
--- 9,17 ----
#define EXTERN /* define EXTERNs in sh.h */
#include "stdh.h"
+ #ifndef OS2
#include <unistd.h>
+ #endif
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
***************
*** 28,33 ****
--- 30,40 ----
Area aperm;
static void reclaim ARGS((void));
+ static int loginshell;
+
+ #ifdef EDIT
+ void x_init();
+ #endif
/*
* shell initialization
***************
*** 208,213 ****
--- 215,224 ----
}
break;
+ case '0':
+ name = "-ksh";
+ break;
+
case 'q':
qflag = 1;
break;
***************
*** 219,225 ****
}
}
if (s->type == SFILE && argi < argc && !flag[FSTDIN]) {
! s->file = name = argv[argi++];
if ((s->u.file = fopen(name, "r")) == NULL)
errorf("%s: cannot open\n", name);
fflag = 1;
--- 230,236 ----
}
}
if (s->type == SFILE && argi < argc && !flag[FSTDIN]) {
! s->file = name = argv[argi];
if ((s->u.file = fopen(name, "r")) == NULL)
errorf("%s: cannot open\n", name);
fflag = 1;
***************
*** 237,243 ****
--- 248,258 ----
s->type = STTY;
}
if (s->type == STTY) {
+ #ifdef OS2
+ ttyfd = getdup(0, FDBASE);
+ #else
ttyfd = fcntl(0, F_DUPFD, FDBASE);
+ #endif
#ifdef F_SETFD
(void) fcntl(ttyfd, F_SETFD, 1);
#else
***************
*** 251,258 ****
--- 266,275 ----
/* initialize job control */
j_init();
+ #ifndef OS2
if (!qflag)
ignoresig(SIGQUIT);
+ #endif
l->argv = &argv[argi];
l->argc = argc - argi;
***************
*** 260,270 ****
--- 277,302 ----
resetopts();
if (name[0] == '-') {
+ loginshell = 1;
flag[FTALKING] = 1;
+ #ifdef OS2
+ arg = substitute("$INIT/profile.ksh", 0);
+ (void) include(*arg ? arg : "/etc/profile.ksh");
+ (void) include("profile.ksh");
+ #else
(void) include("/etc/profile");
(void) include(".profile");
+ #endif
}
+ #ifdef OS2
+ arg = substitute("~/kshrc.ksh", DOTILDE);
+ #else
+ arg = substitute("~/.kshrc", DOTILDE);
+ #endif
+ if (*arg != '\0')
+ (void) include(arg);
+
/* include $ENV */
arg = substitute(strval(global("ENV")), DOTILDE);
if (*arg != '\0')
***************
*** 410,415 ****
--- 442,449 ----
leave(rv)
int rv;
{
+ char *arg;
+
if (e.type == E_TCOM && e.oenv != NULL) /* exec'd command */
unwind();
runtrap(&sigtraps[0]);
***************
*** 418,423 ****
--- 452,467 ----
hist_finish();
}
j_exit();
+ if ( loginshell )
+ {
+ #ifdef OS2
+ arg = substitute("~/kshexit.ksh", DOTILDE);
+ #else
+ arg = substitute("~/.kshexit", DOTILDE);
+ #endif
+ if (*arg != '\0')
+ (void) include(arg);
+ }
exit(rv);
/* NOTREACHED */
}
diff -cbr orig/sh/misc.c new/sh/misc.c
*** orig/sh/misc.c Tue Aug 25 15:21:06 1992
--- new/sh/misc.c Tue Sep 08 11:18:07 1992
***************
*** 214,220 ****
* pattern character are prefixed with MAGIC by expand.
*/
! static char *cclass ARGS((char *, int c));
int
gmatch(s, p)
--- 214,220 ----
* pattern character are prefixed with MAGIC by expand.
*/
! static char *cclass ARGS((char *, int));
int
gmatch(s, p)
***************
*** 295,301 ****
qsortp(base, n, f)
void **base; /* base address */
size_t n; /* elements */
! int (*f)(); /* compare function */
{
qsort1(base, base + n, f);
}
--- 295,301 ----
qsortp(base, n, f)
void **base; /* base address */
size_t n; /* elements */
! int (*f)(void *, void *); /* compare function */
{
qsort1(base, base + n, f);
}
***************
*** 307,312 ****
--- 307,313 ----
register void *t; t = *(a); *(a) = *(c); *(c) = *(b); *(b) = t;\
}
+ void
qsort1(base, lim, f)
void **base, **lim;
int (*f)();
***************
*** 388,403 ****
cleanpath(pwd, dir, clean)
char *pwd, *dir, *clean;
{
! register char *s, *d, *p;
! char *slash = "/";
register int inslash = 0;
d = clean;
! if (*dir != '/') {
s = pwd;
while (*d++ = *s++)
;
! if (d >= clean + 2 && *(d - 2) == '/')
d--;
else
*(d - 1) = '/';
--- 389,408 ----
cleanpath(pwd, dir, clean)
char *pwd, *dir, *clean;
{
! register char *s, *d, *p, c;
! char *slash = DIRSEPSTR;
register int inslash = 0;
d = clean;
! #ifdef OS2
! if (!ISDIRSEP(*dir) && !(isalpha(dir[0]) && dir[1] == ':')) {
! #else
! if (!ISDIRSEP(*dir)) {
! #endif
s = pwd;
while (*d++ = *s++)
;
! if (d >= clean + 2 && ISDIRSEP(*(d - 2)))
d--;
else
*(d - 1) = '/';
***************
*** 405,430 ****
s = dir;
while (*s) {
! if ((*d++ = *s++) == '/' && d > clean + 1) {
! if (*(p = d - 2) == '/') {
--d;
} else if (*p == '.') {
! if (*--p == '/') {
d -= 2;
! } else if (*p == '.' && *--p == '/') {
! while (p > clean && *--p != '/')
;
d = p + 1;
}
}
}
! if (!*s && !inslash && *(s - 1) != '/') {
inslash = 1;
s = slash;
}
}
! if (*(d - 1) == '/' && (d - 1) > clean)
d--;
*d = '\0';
}
--- 410,442 ----
s = dir;
while (*s) {
! c = (*d++ = *s++);
! if (ISDIRSEP(c) && d > clean + 1) {
! p = d - 2;
! if (ISDIRSEP(*p)) {
--d;
} else if (*p == '.') {
! p--;
! if (ISDIRSEP(*p)) {
d -= 2;
! } else if (*p == '.' && --p && ISDIRSEP(*p)) {
! while (p > clean && --p &&
! !ISDIRSEP(*p))
;
d = p + 1;
}
}
}
! if (!*s && !inslash && !ISDIRSEP(*(s - 1))) {
inslash = 1;
s = slash;
}
}
! if (ISDIRSEP(*(d - 1)) && (d - 1) > clean)
! #ifdef OS2
! if (*(d - 2) != ':')
! #endif
d--;
*d = '\0';
}
diff -cbr orig/sh/proto.h new/sh/proto.h
*** orig/sh/proto.h Tue Aug 25 15:20:18 1992
--- new/sh/proto.h Tue Aug 25 15:23:10 1992
***************
*** 180,187 ****
int getn ARGS((char *as));
char * strerror ARGS((int i));
int gmatch ARGS((char *s, char *p));
! void qsortp ARGS((void **base, size_t n, int (*f)()));
! int qsort1 ARGS((void **base, void **lim, int (*f)()));
int xstrcmp ARGS((void *p1, void *p2));
void cleanpath ARGS((char *pwd, char *dir, char *clean));
/* syn.c */
--- 180,187 ----
int getn ARGS((char *as));
char * strerror ARGS((int i));
int gmatch ARGS((char *s, char *p));
! void qsortp ARGS((void **base, size_t n, int (*compare)(void *, void *)));
! void qsort1 ARGS((void **base, void **lim, int (*f)()));
int xstrcmp ARGS((void *p1, void *p2));
void cleanpath ARGS((char *pwd, char *dir, char *clean));
/* syn.c */
diff -cbr orig/sh/sh.h new/sh/sh.h
*** orig/sh/sh.h Tue Aug 25 15:21:07 1992
--- new/sh/sh.h Wed Sep 09 21:49:11 1992
***************
*** 16,22 ****
#endif
#ifndef SHELL
! #define SHELL "/bin/sh" /* shell to exec scripts */
#endif
#ifdef _BSD
--- 16,22 ----
#endif
#ifndef SHELL
! #define SHELL "cmd.exe" /* shell to exec scripts */
#endif
#ifdef _BSD
***************
*** 57,63 ****
#define FDBASE 10 /* First file usable by Shell */
/* you're not going to run setuid shell scripts, are you? */
! #define eaccess(path, mode) access(path, mode)
#define MAGIC (char)0x80 /* prefix for ~*?[ during expand */
#define NOT '!' /* might use ^ */
--- 57,63 ----
#define FDBASE 10 /* First file usable by Shell */
/* you're not going to run setuid shell scripts, are you? */
! #define eaccess(path, mode) (path ? access(path, mode) : -1)
#define MAGIC (char)0x80 /* prefix for ~*?[ during expand */
#define NOT '!' /* might use ^ */
***************
*** 262,267 ****
--- 262,268 ----
void initctypes ARGS((void));
void setctypes ARGS((const char*, int type));
#endif
+
#define ctype(c, t) !!(ctypes[(unsigned char)(c)]&(t))
#define letter(c) ctype(c, C_ALPHA)
#define digit(c) ctype(c, C_DIGIT)
***************
*** 272,277 ****
--- 273,282 ----
#include "lex.h"
#include "proto.h"
+ #ifndef offsetof
+ #define offsetof(type,id) ((size_t)&((type*)NULL)->id)
+ #endif
+
/*
* 91-07-06 <sjg@sun0>
* use my simple debug tracing...
***************
*** 279,285 ****
#include "trace.h"
#ifndef fileno
! #define fileno(p) ((p)->_file)
#endif
/* be sure not to interfere with anyone else's idea about EXTERN */
--- 284,290 ----
#include "trace.h"
#ifndef fileno
! #define fileno(p) ((p)->handle)
#endif
/* be sure not to interfere with anyone else's idea about EXTERN */
***************
*** 294,296 ****
--- 299,319 ----
* comment-column:40
* End:
*/
+
+ #ifdef OS2
+ #define PATHSEP ';'
+ #define DIRSEP '\\'
+ #define DIRSEPSTR "\\"
+ #define ISDIRSEP(c) ((c) == '\\' || (c) == '/')
+ extern char *index_sep(char *path);
+ extern char *rindex_sep(char *path);
+ #define chdir _chdir2
+ #define getcwd _getcwd2
+ #else
+ #define PATHSEP ':'
+ #define DIRSEP '/'
+ #define DIRSEPSTR "/"
+ #define ISDIRSEP(c) ((c) == '/')
+ #define index_sep(p) strchr(p, DIRSEP)
+ #define rindex_sep(p) strrchr(p, DIRSEP)
+ #endif
diff -cbr orig/sh/trap.c new/sh/trap.c
*** orig/sh/trap.c Tue Aug 25 15:20:19 1992
--- new/sh/trap.c Tue Aug 25 16:11:22 1992
***************
*** 14,52 ****
Trap sigtraps [SIGNALS] = {
{0, "EXIT", "Signal 0"}, /* todo: belongs in e.loc->exit */
- {SIGHUP, "HUP", "Hangup"},
{SIGINT, "INT", "Interrupt"},
- {SIGQUIT, "QUIT", "Quit"},
{SIGILL, "ILL", "Illegal instruction"},
{SIGTRAP, "TRAP", "Trace trap"},
#ifdef SIGABRT
! {SIGIOT, "ABRT", "Abort"},
#else
{SIGIOT, "IOT", "IOT instruction"},
#endif
{SIGEMT, "EMT", "EMT trap"},
- {SIGFPE, "FPE", "Floating exception"},
{SIGKILL, "KILL", "Killed"},
#ifdef _MINIX
{SIGUSR1, "USR1", "User defined signal 1"},
- {SIGSEGV, "SEGV", "Memory fault"},
{SIGUSR2, "USR2", "User defined signal 2"},
#else
{SIGBUS, "BUS", "Bus error"},
- {SIGSEGV, "SEGV", "Memory fault"},
{SIGSYS, "SYS", "Bad system call"},
#endif
{SIGPIPE, "PIPE", "Broken pipe"},
{SIGALRM, "ALRM", "Alarm clock"},
- {SIGTERM, "TERM", "Terminated"},
- #ifdef _MINIX
- {SIGSTKFLT, "STKFLT", "Stack fault"},
- #endif
#ifdef _SYSV
{SIGUSR1, "USR1", "User defined signal 1"},
{SIGUSR2, "USR2", "User defined signal 2"},
- {SIGCLD, "CLD", "Death of a child"},
{SIGPWR, "PWR", "Power-fail restart"},
#ifdef JOBS /* todo: need to be more portable */
{SIGTSTP, "TSTP", "Stop"},
{SIGTTIN, "TTIN", "Stop (tty input)"},
--- 14,54 ----
Trap sigtraps [SIGNALS] = {
{0, "EXIT", "Signal 0"}, /* todo: belongs in e.loc->exit */
{SIGINT, "INT", "Interrupt"},
{SIGILL, "ILL", "Illegal instruction"},
+ {SIGFPE, "FPE", "Floating exception"},
+ {SIGSEGV, "SEGV", "Memory fault"},
+ {SIGTERM, "TERM", "Terminated"},
+ #ifdef OS2
+ {SIGBREAK, "BREAK", "Ctrl-Break"},
+ #endif
+ {SIGHUP, "HUP", "Hangup"},
+ {SIGQUIT, "QUIT", "Quit"},
{SIGTRAP, "TRAP", "Trace trap"},
#ifdef SIGABRT
! {SIGABRT, "ABRT", "Abort"},
#else
{SIGIOT, "IOT", "IOT instruction"},
#endif
{SIGEMT, "EMT", "EMT trap"},
{SIGKILL, "KILL", "Killed"},
#ifdef _MINIX
{SIGUSR1, "USR1", "User defined signal 1"},
{SIGUSR2, "USR2", "User defined signal 2"},
+ {SIGSTKFLT, "STKFLT", "Stack fault"},
#else
{SIGBUS, "BUS", "Bus error"},
{SIGSYS, "SYS", "Bad system call"},
#endif
{SIGPIPE, "PIPE", "Broken pipe"},
{SIGALRM, "ALRM", "Alarm clock"},
#ifdef _SYSV
+ #ifndef OS2
{SIGUSR1, "USR1", "User defined signal 1"},
{SIGUSR2, "USR2", "User defined signal 2"},
{SIGPWR, "PWR", "Power-fail restart"},
+ #endif
+ {SIGCLD, "CLD", "Death of a child"},
#ifdef JOBS /* todo: need to be more portable */
{SIGTSTP, "TSTP", "Stop"},
{SIGTTIN, "TTIN", "Stop (tty input)"},
***************
*** 135,141 ****
if (p->signal == SIGINT)
unwind(); /* return to shell() */
else
! return;
if (p->signal == 0) /* ??? */
p->trap = 0;
command(trapstr);
--- 137,143 ----
if (p->signal == SIGINT)
unwind(); /* return to shell() */
else
! return 0;
if (p->signal == 0) /* ??? */
p->trap = 0;
command(trapstr);
diff -cbr orig/sh/tree.c new/sh/tree.c
*** orig/sh/tree.c Sun May 03 18:45:18 1992
--- new/sh/tree.c Sun May 03 19:45:27 1992
***************
*** 9,14 ****
--- 9,15 ----
#include "stdh.h"
#include <errno.h>
#include <setjmp.h>
+ #include <memory.h>
#ifdef __STDC__
# include <stdarg.h>
diff -cbr orig/sh/tty.h new/sh/tty.h
*** orig/sh/tty.h Tue Aug 25 15:20:20 1992
--- new/sh/tty.h Tue Aug 25 16:07:28 1992
***************
*** 6,11 ****
--- 6,12 ----
last edit: 30-Jul-1987 D A Gwyn
*/
+ #ifndef _OS2
#if _BSD_SYSV /* BRL UNIX System V emulation */
#include <termio.h> /* includes <sys/_ioctl.h> */
#ifndef NTTYDISC
***************
*** 35,37 ****
--- 36,39 ----
#endif
#endif
#endif /* _BSD_SYSV */
+ #endif /* OS2 */
diff -cbr orig/sh/var.c new/sh/var.c
*** orig/sh/var.c Tue Aug 25 15:20:20 1992
--- new/sh/var.c Tue Aug 25 15:23:12 1992
***************
*** 6,11 ****
--- 6,12 ----
#include <errno.h>
#include <setjmp.h>
#include <time.h>
+ #include <sys/types.h>
#include "sh.h"
#include "expand.h"
diff -cbr orig/sh/vi.c new/sh/vi.c
*** orig/sh/vi.c Tue Aug 25 15:20:21 1992
--- new/sh/vi.c Tue Sep 08 13:04:13 1992
***************
*** 73,79 ****
#define isundoable(c) (!(classify[c]&U_))
#define issrch(c) (classify[c]&S_)
! char classify[128] = {
B_, 0, 0, 0, 0, 0, O_, 0,
#if 1 /* Mike B. changes */
C_|M_, 0, O_, 0, O_, O_, O_, 0,
--- 73,79 ----
#define isundoable(c) (!(classify[c]&U_))
#define issrch(c) (classify[c]&S_)
! char classify[256] = {
B_, 0, 0, 0, 0, 0, O_, 0,
#if 1 /* Mike B. changes */
C_|M_, 0, O_, 0, O_, O_, O_, 0,
***************
*** 1134,1140 ****
static int pwidth; /* width of prompt */
static int winwidth; /* width of window */
/*static char *wbuf[2]; /* window buffers */
! static char wbuf[2][80-3]; /* window buffers */ /* TODO */
static int win; /* window buffer in use */
static char morec; /* more character at right of window */
static int lastref; /* argument to last refresh() */
--- 1134,1140 ----
static int pwidth; /* width of prompt */
static int winwidth; /* width of window */
/*static char *wbuf[2]; /* window buffers */
! static char wbuf[2][128-3]; /* window buffers */ /* TODO */
static int win; /* window buffer in use */
static char morec; /* more character at right of window */
static int lastref; /* argument to last refresh() */
***************
*** 1597,1603 ****
}
#if 0
/*
! * Hack to fix teh ^r redraw problem, but it redraws way too much.
* Probably unacceptable at low baudrates. Someone please fix this
*/
else
--- 1597,1603 ----
}
#if 0
/*
! * Hack to fix the ^r redraw problem, but it redraws way too much.
* Probably unacceptable at low baudrates. Someone please fix this
*/
else
***************
*** 1664,1674 ****
getch()
{
! char buf;
if (read(ttyfd, &buf, 1) != 1)
return -1;
if ((buf & 0x7f) == Ctrl('c')) {
/*
* If you hit ctrl-c, the buffer was left in a
* strange state; the next command typed was
--- 1664,1685 ----
getch()
{
! unsigned char buf;
+ #ifdef OS2
+ do
+ {
+ buf = _read_kbd(0, 1, 0);
+ if ( buf == 0 || buf == 0xE0 )
+ _read_kbd(0, 1, 0);
+ }
+ while ( buf == 0 || buf == 0xE0 );
+ if (buf == Ctrl('c')) {
+ #else
if (read(ttyfd, &buf, 1) != 1)
return -1;
if ((buf & 0x7f) == Ctrl('c')) {
+ #endif
/*
* If you hit ctrl-c, the buffer was left in a
* strange state; the next command typed was
***************
*** 1688,1696 ****
--- 1699,1713 ----
undo->cursor = 0;
x_mode(FALSE);
trapsig(SIGINT);
+ #ifdef OS2
+ } else if (buf == Ctrl('d'))
+ return -1;
+ return buf;
+ #else
} else if ((buf & 0x7f) == Ctrl('d'))
return -1;
return buf & 0x7f;
+ #endif
}