diff --git a/src/cmd/ksh93/edit/edit.c b/src/cmd/ksh93/edit/edit.c index 111c1258d539..fd616a4d689d 100644 --- a/src/cmd/ksh93/edit/edit.c +++ b/src/cmd/ksh93/edit/edit.c @@ -272,7 +272,7 @@ int ed_window(void) { // void ed_flush(Edit_t *ep) { int n = ep->e_outptr - ep->e_outbase; - int fd = ERRIO; + int fd = STDERR_FILENO; if (n <= 0) return; write(fd, ep->e_outbase, (unsigned)n); @@ -282,7 +282,7 @@ void ed_flush(Edit_t *ep) { // // Send the bell character ^G to the terminal. // -void ed_ringbell(void) { write(ERRIO, bellchr, 1); } +void ed_ringbell(void) { write(STDERR_FILENO, bellchr, 1); } // // Send a carriage return line feed to the terminal. diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index 5ab3d472a6ba..800c5d7bf58b 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -176,7 +176,7 @@ int ed_emacsread(void *context, int fd, char *buff, int scend, int reedit) { Prompt = prompt; ep->screen = Screen; ep->lastdraw = FINAL; - if (tty_raw(ERRIO, 0) < 0) { + if (tty_raw(STDERR_FILENO, 0) < 0) { return reedit ? reedit : ed_read(context, fd, buff, scend, 0); } raw = 1; @@ -207,7 +207,7 @@ int ed_emacsread(void *context, int fd, char *buff, int scend, int reedit) { draw(ep, FINAL); ed_flush(ep->ed); } - tty_cooked(ERRIO); + tty_cooked(STDERR_FILENO); if (i == UEOF) return 0; // EOF return -1; // some other error } @@ -266,7 +266,7 @@ int ed_emacsread(void *context, int fd, char *buff, int scend, int reedit) { } case EOFCHAR: { ed_flush(ep->ed); - tty_cooked(ERRIO); + tty_cooked(STDERR_FILENO); return 0; } case '\t': { @@ -600,7 +600,7 @@ int ed_emacsread(void *context, int fd, char *buff, int scend, int reedit) { *out = '\0'; } draw(ep, FINAL); - tty_cooked(ERRIO); + tty_cooked(STDERR_FILENO); if (ed->e_nlist) { ed->e_nlist = 0; stakset(ed->e_stkptr, ed->e_stkoff); diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index ccacf93ff694..83963b78743c 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -194,7 +194,9 @@ int ed_viread(void *context, int fd, char *shbuf, int nchar, int reedit) { shbuf[reedit] = 0; // Set raw mode. - if (tty_raw(ERRIO, 0) < 0) return reedit ? reedit : ed_read(context, fd, shbuf, nchar, 0); + if (tty_raw(STDERR_FILENO, 0) < 0) { + return reedit ? reedit : ed_read(context, fd, shbuf, nchar, 0); + } i = last_virt - 1; // Initialize some things. @@ -246,7 +248,7 @@ int ed_viread(void *context, int fd, char *shbuf, int nchar, int reedit) { sync_cursor(vp); } virtual[0] = '\0'; - tty_cooked(ERRIO); + tty_cooked(STDERR_FILENO); if (i == UEOF) return 0; // EOF if (i == UINTR) return -1; // interrupt @@ -263,7 +265,7 @@ int ed_viread(void *context, int fd, char *shbuf, int nchar, int reedit) { vigetline(vp, APPEND); if (vp->ed->e_multiline) cursor(vp, last_phys); // Add a new line if user typed unescaped \n to cause the shell to process the line. - tty_cooked(ERRIO); + tty_cooked(STDERR_FILENO); if (ed->e_nlist) { ed->e_nlist = 0; stkset(ed->sh->stk, ed->e_stkptr, ed->e_stkoff); diff --git a/src/cmd/ksh93/include/io.h b/src/cmd/ksh93/include/io.h index 71b4ae25ddca..c886a997eec5 100644 --- a/src/cmd/ksh93/include/io.h +++ b/src/cmd/ksh93/include/io.h @@ -29,9 +29,6 @@ #define IOBSIZE (SF_BUFSIZE * _ast_sizeof_pointer) #define IOMAXTRY 20 -// Used for output of shell errors. -#define ERRIO 2 - #define IOREAD 001 #define IOWRITE 002 #define IODUP 004 diff --git a/src/cmd/ksh93/sh/io.c b/src/cmd/ksh93/sh/io.c index 6317932b19ca..6a676ff50e85 100644 --- a/src/cmd/ksh93/sh/io.c +++ b/src/cmd/ksh93/sh/io.c @@ -2306,15 +2306,15 @@ static_fn void sftrack(Sfio_t *sp, int flag, void *data) { #ifdef DEBUG if (flag == SF_READ || flag == SF_WRITE) { char *z = fmtbase((long)getpid(), 0, 0); - write(ERRIO, z, strlen(z)); - write(ERRIO, ": ", 2); - write(ERRIO, "attempt to ", 11); + write(STDERR_FILENO, z, strlen(z)); + write(STDERR_FILENO, ": ", 2); + write(STDERR_FILENO, "attempt to ", 11); if (flag == SF_READ) { - write(ERRIO, "read from", 9); + write(STDERR_FILENO, "read from", 9); } else { - write(ERRIO, "write to", 8); + write(STDERR_FILENO, "write to", 8); } - write(ERRIO, " locked stream\n", 15); + write(STDERR_FILENO, " locked stream\n", 15); return; } #endif diff --git a/src/cmd/ksh93/sh/main.c b/src/cmd/ksh93/sh/main.c index 18443ab3fa53..20a591595ae3 100644 --- a/src/cmd/ksh93/sh/main.c +++ b/src/cmd/ksh93/sh/main.c @@ -139,7 +139,7 @@ int sh_main(int ac, char *av[], Shinit_f userinit) { // Decide whether shell is interactive. if (!sh_isoption(shp, SH_INTERACTIVE) && !sh_isoption(shp, SH_TFLAG) && !sh_isoption(shp, SH_CFLAG) && sh_isoption(shp, SH_SFLAG) && tty_check(0) && - tty_check(ERRIO)) { + tty_check(STDERR_FILENO)) { sh_onoption(shp, SH_INTERACTIVE); } if (sh_isoption(shp, SH_INTERACTIVE)) { diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index 80f4fa29b1a4..559cced1481e 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -1102,7 +1102,7 @@ int sh_exec(Shell_t *shp, const Shnode_t *t, int flags) { shp->exitval = (*shp->bltinfun)(argn, com, (void *)bp); sfsync(NULL); } - if (error_info.flags & ERROR_INTERACTIVE) tty_check(ERRIO); + if (error_info.flags & ERROR_INTERACTIVE) tty_check(STDERR_FILENO); ((Shnode_t *)t)->com.comstate = shp->bltindata.data; bp->data = (void *)save_data; if (shp->exitval && errno == EINTR && shp->lastsig) {