Bash on 4Ds
dixons%phvax.dnet at SMITHKLINE.COM
dixons%phvax.dnet at SMITHKLINE.COM
Sat Feb 3 00:22:14 AEST 1990
"Lonhyn T. Jasinskyj" <amelia!ew01!lonhyn at ames.arc.nasa.gov> writes
>Has anyone tried/been successful in compiling bash (Born again Shell)
>on Iris 4Ds? I just recently migrated to an Iris from a Sun and miss
>a shell with proper command line editing (was originally spoiled by
...
Here is a context diff to get Bash 1.04 to run on 4Ds. I have been using
it for several months without problem. Thanks to Jim Barton at SGI for
giving me the secret to getting job control to work.
Scott Dixon (dixons at smithkline.com)
--------------------cut----------------cut------------------------------
*** ../bash-orig/Makefile Sat Nov 4 12:36:18 1989
--- Makefile Tue Nov 14 22:52:06 1989
***************
*** 45,56 ****
# Use i386 for PC type 386 boxes. (Compaq, etc.)
# SUN3, SUN4, SUN386i, VAX, SONY, CONVEX, HP, HP9KS300, i386, NeXT, AIX,
# ATT3B, ATT386
! TARGET = SUN3
# The name of the target operating system. There isn't such a big
# difference between SUNOS3 and Bsd. But there might be in the future.
# SUNOS3, SUNOS4, SYSV, Bsd, HPUX, UNIXPC
! OS = SUNOS4
# You only need this if you are hacking the shell in a location
# that doesn't do enough backups, or does a poor job. In that
--- 45,56 ----
# Use i386 for PC type 386 boxes. (Compaq, etc.)
# SUN3, SUN4, SUN386i, VAX, SONY, CONVEX, HP, HP9KS300, i386, NeXT, AIX,
# ATT3B, ATT386
! TARGET = IRIS4D
# The name of the target operating system. There isn't such a big
# difference between SUNOS3 and Bsd. But there might be in the future.
# SUNOS3, SUNOS4, SYSV, Bsd, HPUX, UNIXPC
! OS = SYSV
# You only need this if you are hacking the shell in a location
# that doesn't do enough backups, or does a poor job. In that
***************
*** 71,92 ****
# HP-UX compilation requires the BSD library.
#LOCAL_LIBS = -lBSD
# Xenix requires -ldir -lx. It is also required in the readline Makefile.
#LOCAL_LIBS = -ldir -lx
! GCC_SUNOS4_FLAG = -Bstatic
DEBUG_FLAGS = $(PROFILE_FLAGS) -g $(GCC_SUNOS4_FLAG)
LDFLAGS = $(DEBUG_FLAGS)
! CFLAGS = $(DEBUG_FLAGS) -D${TARGET} -DTARGET=${TARGET} -D${OS}
CPPFLAGS= -I$(LIBSRC)
# If you don't have Bison use "yacc". Otherwise use "bison -y".
! #BISON = yacc
! BISON = bison -y
# If you don't have Gcc use cc.
! CC = gcc -traditional
####################################################################
--- 71,97 ----
# HP-UX compilation requires the BSD library.
#LOCAL_LIBS = -lBSD
+ #Iris needs sun and bsd libs
+ LOCAL_LIBS = -lsun -lbsd
# Xenix requires -ldir -lx. It is also required in the readline Makefile.
#LOCAL_LIBS = -ldir -lx
! #GCC_SUNOS4_FLAG = -Bstatic
DEBUG_FLAGS = $(PROFILE_FLAGS) -g $(GCC_SUNOS4_FLAG)
LDFLAGS = $(DEBUG_FLAGS)
! CFLAGS = $(DEBUG_FLAGS) -D${TARGET} -DTARGET=${TARGET} -D${OS} -DVOID=int
CPPFLAGS= -I$(LIBSRC)
+ #Iris requires another include area for some files
+ CFL2 = -I/usr/include/bsd
# If you don't have Bison use "yacc". Otherwise use "bison -y".
! BISON = yacc
! #BISON = bison -y
# If you don't have Gcc use cc.
! #CC = gcc -traditional
! CC = cc
####################################################################
***************
*** 114,120 ****
MALLOC = $(ALLOC_SOURCE)malloc.o
MALLOC_FLAGS = -Drcheck -Dbotch=programming_error
#MALLOC= $(ALLOC_SOURCE)malloc.o
! #ALLOCA= $(ALLOC_SOURCE)alloca.o
ALLOC_HEADERS = $(ALLOC_SOURCE)getpagesize.h
ALLOC_FILES = $(ALLOC_SOURCE)malloc.c $(ALLOC_SOURCE)alloca.c\
--- 119,125 ----
MALLOC = $(ALLOC_SOURCE)malloc.o
MALLOC_FLAGS = -Drcheck -Dbotch=programming_error
#MALLOC= $(ALLOC_SOURCE)malloc.o
! ALLOCA= $(ALLOC_SOURCE)alloca.o
ALLOC_HEADERS = $(ALLOC_SOURCE)getpagesize.h
ALLOC_FILES = $(ALLOC_SOURCE)malloc.c $(ALLOC_SOURCE)alloca.c\
***************
*** 230,238 ****
(cd $(RLIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
CFLAGS='$(CFLAGS) -DSHELL')
! $(TERMCAP): $(TERMCAP_SOURCE)
! (cd $(LIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
! CFLAGS='$(CFLAGS) -I.')
shell.o: shell.h flags.h shell.c
$(CC) $(CFG_FLAGS) $(CFLAGS) $(CPPFLAGS) -c shell.c
--- 235,243 ----
(cd $(RLIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
CFLAGS='$(CFLAGS) -DSHELL')
! #$(TERMCAP): $(TERMCAP_SOURCE)
! # (cd $(LIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
! # CFLAGS='$(CFLAGS) -I.')
shell.o: shell.h flags.h shell.c
$(CC) $(CFG_FLAGS) $(CFLAGS) $(CPPFLAGS) -c shell.c
***************
*** 247,260 ****
$(CC) -I$(ALLOC_SOURCE) $(CFLAGS) $(MALLOC_FLAGS) -c $*.c &&\
mv `basename $*`.o $(MALLOC)
! #$(ALLOCA): $(ALLOC_FILES)
! # $(CC) -I$(ALLOC_SOURCE) $(CFLAGS) -o $(ALLOCA) -c $*.c
! # mv `basename $*`.o $(ALLOCA)
bashline.o: bashline.c config.h $(RLIBSRC)readline.h variables.h builtins.h
jobs.o: jobs.c nojobs.c jobs.h config.h
version.o: version.h version.c .build
general.o: general.c shell.h
y.tab.h: y.tab.c
alias.o: alias.h alias.c
subst.o: subst.c shell.h
--- 252,267 ----
$(CC) -I$(ALLOC_SOURCE) $(CFLAGS) $(MALLOC_FLAGS) -c $*.c &&\
mv `basename $*`.o $(MALLOC)
! $(ALLOCA): $(ALLOC_FILES)
! $(CC) -I$(ALLOC_SOURCE) $(CFLAGS) -o $(ALLOCA) -c $*.c
! mv `basename $*`.o $(ALLOCA)
bashline.o: bashline.c config.h $(RLIBSRC)readline.h variables.h builtins.h
jobs.o: jobs.c nojobs.c jobs.h config.h
+ $(CC) $(CFLAGS) $(CFL2) -c jobs.c
version.o: version.h version.c .build
general.o: general.c shell.h
+ $(CC) $(TRADITIONAL) $(CFLAGS) $(CFL2) -c general.c
y.tab.h: y.tab.c
alias.o: alias.h alias.c
subst.o: subst.c shell.h
*** ../bash-orig/builtins.c Mon Oct 30 23:06:14 1989
--- builtins.c Tue Nov 14 22:43:11 1989
***************
*** 3257,3264 ****
}
else
{ /* Must be a job spec. Check it out. */
- int oldmask = sigblock (sigmask (SIGCHLD));
int job = get_job_spec (list);
if (job < 0 || job >= job_slots || !jobs[job])
{
--- 3257,3264 ----
}
else
{ /* Must be a job spec. Check it out. */
int job = get_job_spec (list);
+ int oldmask = sigblock (sigmask (SIGCHLD));
if (job < 0 || job >= job_slots || !jobs[job])
{
*** ../bash-orig/config.h Thu Sep 21 20:41:17 1989
--- config.h Tue Nov 14 22:43:11 1989
***************
*** 2,8 ****
#ifndef _CONFIG_
#define _CONFIG_
-
#ifndef VOID
#define VOID void
#endif
--- 2,7 ----
***************
*** 35,41 ****
#define JOB_CONTROL
/* Note that System V machines don't support job control. */
! #if defined (SYSV) && !defined (HP9KS300)
#undef JOB_CONTROL
#endif /* SYSV && !HP9KS300 */
--- 34,40 ----
#define JOB_CONTROL
/* Note that System V machines don't support job control. */
! #if defined (SYSV) && !defined (HP9KS300) && !defined (IRIS4D)
#undef JOB_CONTROL
#endif /* SYSV && !HP9KS300 */
*** ../bash-orig/glob.c Sat Sep 23 00:35:45 1989
--- glob.c Wed Nov 15 12:16:18 1989
***************
*** 21,27 ****
#include <sys/types.h>
! #if defined(USGr3) || defined(DIRENT)
#include <dirent.h>
#define direct dirent
#define D_NAMLEN(d) strlen((d)->d_name)
--- 21,27 ----
#include <sys/types.h>
! #if defined(USGr3) || defined(DIRENT) || defined(SYSV)
#include <dirent.h>
#define direct dirent
#define D_NAMLEN(d) strlen((d)->d_name)
***************
*** 34,40 ****
# endif /* USG. */
#endif /* USGr3 or DIRENT. */
! #ifdef USG
#include <memory.h>
#include <string.h>
#define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
--- 34,40 ----
# endif /* USG. */
#endif /* USGr3 or DIRENT. */
! #if defined(USG) || defined(SYSV)
#include <memory.h>
#include <string.h>
#define bcopy(s, d, n) ((void) memcpy ((d), (s), (n)))
*** ../bash-orig/jobs.c Sat Nov 4 11:54:16 1989
--- jobs.c Wed Nov 15 11:44:23 1989
***************
*** 35,40 ****
--- 35,59 ----
#include <sgtty.h>
#include "shell.h"
#include "jobs.h"
+ #ifdef IRIS4D
+ #define setpgrp BSDsetpgrp
+ #include <termio.h>
+ #define getpgrp BSDgetpgrp
+ # define ioctl jioctl
+ # define TIOCGETD 50000
+ # define TIOCSETD 50001
+ # define TIOCGETP 50002
+ # define TIOCSETP 50003
+ # define TIOCSETN 50004
+ # define FIOCLEX 50005
+ # define OTTYDISC 0
+ # define CNSUSP 26
+ # define VSUSP VSWTCH
+ #define signal sigset
+ #ifndef sigmask
+ #define sigmask(x) (1 << ((x)-1))
+ #endif
+ #endif
/* Not all systems define errno in errno.h. */
extern int errno;
***************
*** 265,272 ****
/* Delete all DEAD jobs that the user had received notification about. */
cleanup_dead_jobs ()
{
- int oldmask = sigblock (sigmask (SIGCHLD));
register int i;
for (i = 0; i < job_slots; i++)
if (jobs[i] && JOBSTATE (i) == JDEAD && jobs[i]->notified)
--- 284,291 ----
/* Delete all DEAD jobs that the user had received notification about. */
cleanup_dead_jobs ()
{
register int i;
+ int oldmask = sigblock (sigmask (SIGCHLD));
for (i = 0; i < job_slots; i++)
if (jobs[i] && JOBSTATE (i) == JDEAD && jobs[i]->notified)
***************
*** 702,708 ****
--- 721,731 ----
/* When we end a job abnormally, or if we stop a job, we set the tty to the
state kept in here. When a job ends normally, we set the state in here
to the state of the tty. */
+ #ifdef IRIS4D
+ static struct termio shell_tty_info;
+ #else
static struct sgttyb shell_tty_info;
+ #endif
/* Fill the contents of shell_tty_info with the current tty info. */
get_tty_state ()
***************
*** 863,869 ****
--- 886,896 ----
if (child->running ||
((job != NO_JOB) && (JOBSTATE (job) == JRUNNING)))
{
+ #ifdef IRIS4D
+ sigpause(SIGCHLD);
+ #else
sigpause (0);
+ #endif
goto wait_loop;
}
***************
*** 1040,1048 ****
start_job (job, foreground)
int job, foreground;
{
- int oldmask = sigblock (sigmask (SIGCHLD));
int already_running = jobs[job]->state == JRUNNING;
register PROCESS *p;
if (!foreground && already_running)
{
--- 1067,1075 ----
start_job (job, foreground)
int job, foreground;
{
int already_running = jobs[job]->state == JRUNNING;
register PROCESS *p;
+ int oldmask = sigblock (sigmask (SIGCHLD));
if (!foreground && already_running)
{
***************
*** 1109,1115 ****
jobs[job]->notified = 1;
killpg (jobs[job]->pgrp, SIGCONT);
}
-
sigsetmask (oldmask);
if (foreground)
{
--- 1136,1141 ----
***************
*** 1132,1141 ****
kill_pid (pid, signal, group)
int pid, signal, group;
{
- int old_mask = sigblock (SIGCHLD);
register PROCESS *p = find_pipeline (pid);
int job = find_job (pid);
int result;
if (group)
{
--- 1158,1167 ----
kill_pid (pid, signal, group)
int pid, signal, group;
{
register PROCESS *p = find_pipeline (pid);
int job = find_job (pid);
int result;
+ int old_mask = sigblock (SIGCHLD);
if (group)
{
***************
*** 1434,1439 ****
--- 1460,1468 ----
}
original_pgrp = shell_pgrp;
+ #ifdef IRIS4D
+ setpgrp(0,getpid());
+ #endif
shell_pgrp = getpid ();
give_terminal_to (shell_pgrp);
setpgrp (0, shell_pgrp);
***************
*** 1454,1460 ****
job_control = arg;
if (job_control)
! signal (SIGCHLD, flush_child);
else
signal (SIGCHLD, SIG_DFL);
}
--- 1483,1490 ----
job_control = arg;
if (job_control)
! {signal (SIGCHLD, flush_child);
! }
else
signal (SIGCHLD, SIG_DFL);
}
***************
*** 1532,1534 ****
--- 1562,1656 ----
}
}
#endif /* JOB_CONTROL */
+
+ #ifdef IRIS4D
+ #undef ioctl
+ #include <fcntl.h>
+
+ static int
+ jioctl(fd, cmd, arg)
+ int fd;
+ int cmd;
+ long arg;
+ {
+ struct termio tb;
+
+ switch (cmd) {
+ case FIOCLEX:
+ fcntl(fd, F_SETFD, 1);
+ break;
+ case TIOCGETD:
+ ioctl(fd, TCGETA, &tb);
+ *((int *) arg) = tb.c_line;
+ break;
+ case TIOCSETD:
+ ioctl(fd, TCGETA, &tb);
+ tb.c_line = *((int *) arg);
+ ioctl(fd, TCSETA, &tb);
+ break;
+ case TIOCGETP:
+ return(ioctl(fd, TCGETA, arg));
+ case TIOCSETP:
+ return(ioctl(fd, TCSETA, arg));
+ case TIOCSETN:
+ return(ioctl(fd, TCSETAF, arg));
+ default:
+ return(ioctl(fd, cmd, arg));
+ }
+ return(0);
+ }
+
+ /*
+ * This is how one sends a signal to a process group in system V.
+ */
+ killpg(pgrp, signo)
+ int pgrp;
+ int signo;
+ {
+ if (pgrp < 0)
+ pgrp = -pgrp;
+ kill(-pgrp, signo);
+ }
+
+
+
+ int sigheld = 0; /* Mask of held signals */
+
+ int sigblock (sigs)
+ int sigs;
+ {
+ int i,old;
+ for (i = 0; i < NSIG; i++)
+ if (sigs & sigbit (i))
+ sighold (i);
+ old = sigheld;
+ sigheld |= sigs;
+ return(old);
+ }
+
+ sigsetmask(sigset)
+ int sigset;
+ {
+ int newheld,newrel,tmp;
+ newheld = sigset & ~sigheld;
+ newrel = sigheld & ~sigset;
+ tmp = sigblock(newheld);
+ sigfree(newrel);
+ }
+
+ sigfree (sigs)
+ int sigs;
+ {
+ int i;
+ for (i = 0; i < NSIG; i++)
+ if (sigs & sigbit (i))
+ sigrelse (i);
+ sigheld &= ~sigs;
+ }
+
+ sigbit (i)
+ int i;
+ {
+ return 1 << (i - 1);
+ }
+ #endif
*** ../bash-orig/jobs.h Sun Aug 20 22:29:49 1989
--- jobs.h Tue Nov 14 22:43:13 1989
***************
*** 2,7 ****
--- 2,10 ----
#include "quit.h"
+ #ifdef IRIS4D
+ #include <sys/wait.h>
+ #endif
#if !defined (SYSV) || defined (UNIXPC)
#include <sys/wait.h>
#else
*** ../bash-orig/trap.c Sat Aug 5 11:27:10 1989
--- trap.c Tue Nov 14 22:43:13 1989
***************
*** 60,65 ****
--- 60,78 ----
"SIGUSR2",
"SIGCLD",
"SIGPWR",
+ #ifdef IRIS4D
+ "SIGSTOP", /* sendable stop signal not from tty */
+ "SIGTSTP", /* stop signal from tty */
+ "SIGPOLL",
+ "SIGIO", /* input/output possible signal */
+ "SIGURG", /* urgent condition on IO channel */
+ "SIGWINCH", /* window changed */
+ "SIGVTALRM", /* virtual time alarm */
+ "SIGPROF", /* profiling time alarm */
+ "SIGCONT", /* continue a stopped process */
+ "SIGTTIN", /* to readers pgrp upon background tty read */
+ "SIGTTOU", /* like TTIN for output if (tp->t_local<OSTOP) */
+ #endif
#if NSIG == 23
"SIGJUNK1",
"SIGJUNK2",
*** ../bash-orig/variables.c Sun Sep 17 20:02:43 1989
--- variables.c Tue Nov 14 22:43:14 1989
***************
*** 27,33 ****
--- 27,35 ----
#include "version.h"
#ifdef SYSV
+ #ifndef IRIS4D
struct passwd *getpwuid (), *getpwent ();
+ #endif
#endif
/* The list of shell variables that the user has created, or that came from
*** ../bash-orig/version.h Sat Nov 4 12:40:00 1989
--- version.h Tue Nov 14 23:38:08 1989
***************
*** 4,7 ****
/* The distribution version number of this shell. */
#define DISTVERSION 1.04
/* The last built version of this shell. */
! #define BUILDVERSION 1
--- 4,7 ----
/* The distribution version number of this shell. */
#define DISTVERSION 1.04
/* The last built version of this shell. */
! #define BUILDVERSION 2
*** ../bash-orig/alloc-files/malloc.c Wed Sep 13 20:02:16 1989
--- alloc-files/malloc.c Tue Nov 14 22:43:26 1989
***************
*** 144,149 ****
--- 144,152 ----
#include "config.h"
#endif /* emacs */
+ #ifdef IRIS4D
+ #define USG
+ #endif
#ifdef HPUX
#define USG
#endif
*** ../bash-orig/readline/readline.c Sat Nov 4 08:42:01 1989
--- readline/readline.c Wed Nov 15 00:06:55 1989
***************
*** 63,70 ****
--- 63,72 ----
#include <pwd.h>
#ifdef SYSV
+ #ifndef IRIS4D
struct passwd *getpwuid (), *getpwent ();
#endif
+ #endif
#define HACK_TERMCAP_MOTION
***************
*** 133,139 ****
/* If on, then readline handles signals in a way that doesn't screw. */
#define HANDLE_SIGNALS
! #if defined (SYSV)
#ifdef HANDLE_SIGNALS
#undef HANDLE_SIGNALS
#endif
--- 135,141 ----
/* If on, then readline handles signals in a way that doesn't screw. */
#define HANDLE_SIGNALS
! #if defined (SYSV) && !defined (IRIS4D)
#ifdef HANDLE_SIGNALS
#undef HANDLE_SIGNALS
#endif
More information about the Comp.sys.sgi
mailing list