Skip to content

Commit

Permalink
Importing bin/sh
Browse files Browse the repository at this point in the history
/etc/profile enables by default tabcompletion, as well as emacs mode,
in order to keep the old MINIX ash behavior.

Note: The shell now refuses to source a script without a relative or
      absolute path.
      This means:
        - '. myscript.sh' fails, while
        - '. ./myscript.sh' succeeds

Change-Id: I0be89b0747bd005e4c05cadb937af86883627dc6
  • Loading branch information
sambuc authored and Gerrit Code Review committed Aug 29, 2014
1 parent 2d64210 commit d90bee9
Show file tree
Hide file tree
Showing 117 changed files with 12,247 additions and 10,646 deletions.
2 changes: 1 addition & 1 deletion bin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93

SUBDIR= cat chmod cp date df echo ed expr hostname \
kill ksh ln ls mkdir mv pax pwd rm rmdir \
kill ksh ln ls mkdir mv pax pwd rm rmdir sh \
sleep stty sync test

.include <bsd.subdir.mk>
88 changes: 88 additions & 0 deletions bin/sh/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# $NetBSD: Makefile,v 1.99 2012/12/02 12:55:27 apb Exp $
# @(#)Makefile 8.4 (Berkeley) 5/5/95

.include <bsd.own.mk>

YHEADER=1
PROG= sh
SHSRCS= alias.c cd.c echo.c error.c eval.c exec.c expand.c \
histedit.c input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
mystring.c options.c parser.c redir.c show.c trap.c output.c var.c \
test.c kill.c syntax.c
GENSRCS=arith.c arith_lex.c builtins.c init.c nodes.c
GENHDRS=arith.h builtins.h nodes.h token.h
SRCS= ${SHSRCS} ${GENSRCS}

DPSRCS+=${GENHDRS}

LDADD+= -ll -ledit -lterminfo
DPADD+= ${LIBL} ${LIBEDIT} ${LIBTERMINFO}

LFLAGS= -8 # 8-bit lex scanner for arithmetic

# Environment for scripts executed during build.
SCRIPT_ENV= \
AWK=${TOOL_AWK:Q} \
SED=${TOOL_SED:Q}

# The .depend file can get references to these temporary files
.OPTIONAL: lex.yy.c y.tab.c

.ifdef CRUNCHEDPROG
LFLAGS+=-L
YFLAGS+=-l
.endif

CPPFLAGS+=-DSHELL -I. -I${.CURDIR}
#XXX: For testing only.
#CPPFLAGS+=-DDEBUG=2
#COPTS+=-g
#CFLAGS+=-funsigned-char
#TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char

.ifdef SMALLPROG
CPPFLAGS+=-DSMALL
.else
SRCS+=printf.c
.endif

.PATH: ${.CURDIR}/bltin ${NETBSDSRCDIR}/bin/test \
${NETBSDSRCDIR}/usr.bin/printf \
${NETBSDSRCDIR}/bin/kill

CLEANFILES+= ${GENSRCS} ${GENHDRS} y.tab.h
CLEANFILES+= trace

token.h: mktokens
${_MKTARGET_CREATE}
${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC}

.ORDER: builtins.h builtins.c
builtins.h builtins.c: mkbuiltins shell.h builtins.def
${_MKTARGET_CREATE}
${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} ${.OBJDIR}
[ -f builtins.h ]

init.c: mkinit.sh ${SHSRCS}
${_MKTARGET_CREATE}
${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC}

.ORDER: nodes.h nodes.c
nodes.c nodes.h: mknodes.sh nodetypes nodes.c.pat
${_MKTARGET_CREATE}
${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} ${.OBJDIR}
[ -f nodes.h ]

.if ${USETOOLS} == "yes"
NBCOMPATLIB= -L${TOOLDIR}/lib -lnbcompat
.endif

.if make(install)
SUBDIR+=USD.doc
.endif

COPTS.printf.c = -Wno-format-nonliteral
COPTS.jobs.c = -Wno-format-nonliteral

.include <bsd.prog.mk>
.include <bsd.subdir.mk>
15 changes: 6 additions & 9 deletions minix/commands/ash/TOUR → bin/sh/TOUR
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# $NetBSD: TOUR,v 1.10 2008/11/15 17:01:38 snj Exp $
# @(#)TOUR 8.1 (Berkeley) 5/31/93
# $FreeBSD: src/bin/sh/TOUR,v 1.6 1999/08/27 23:15:07 peter Exp $

NOTE -- This is the original TOUR paper distributed with ash and
does not represent the current state of the shell. It is provided anyway
Expand All @@ -22,7 +22,7 @@ SOURCE CODE GENERATORS: Files whose names begin with "mk" are
programs that generate source code. A complete list of these
programs is:

program intput files generates
program input files generates
------- ------------ ---------
mkbuiltins builtins builtins.h builtins.c
mkinit *.c init.c
Expand Down Expand Up @@ -91,7 +91,7 @@ INTERRUPTS: In an interactive shell, an interrupt will cause an
EXINT exception to return to the main command loop. (Exception:
EXINT is not raised if the user traps interrupts using the trap
command.) The INTOFF and INTON macros (defined in exception.h)
provide uninterruptable critical sections. Between the execution
provide uninterruptible critical sections. Between the execution
of INTOFF and the execution of INTON, interrupt signals will be
held for later delivery. INTOFF and INTON can be nested.

Expand All @@ -110,7 +110,7 @@ string was going to be:
p = stackptr;
*p++ = c; /* repeated as many times as needed */
stackptr = p;
The folloing three macros (defined in memalloc.h) perform these
The following three macros (defined in memalloc.h) perform these
operations, but grow the stack if you run off the end:
STARTSTACKSTR(p);
STPUTC(c, p); /* repeated as many times as needed */
Expand Down Expand Up @@ -232,7 +232,7 @@ control is defined.
REDIR.C: Ash allows file descriptors to be redirected and then
restored without forking off a child process. This is accom-
plished by duplicating the original file descriptors. The redir-
tab structure records where the file descriptors have be dupli-
tab structure records where the file descriptors have been dupli-
cated to.

EXEC.C: The routine find_command locates a command, and enters
Expand Down Expand Up @@ -327,7 +327,7 @@ is called at appropriate points to actually handle the signal.
When an interrupt is caught and no trap has been set for that
signal, the routine "onint" in error.c is called.

OUTPUT: Ash uses it's own output routines. There are three out-
OUTPUT: Ash uses its own output routines. There are three out-
put structures allocated. "Output" represents the standard out-
put, "errout" the standard error, and "memout" contains output
which is to be stored in memory. This last is used when a buil-
Expand Down Expand Up @@ -355,6 +355,3 @@ cause the preprocessor can't handle functions with a variable
number of arguments. Defining DEBUG also causes the shell to
generate a core dump if it is sent a quit signal. The tracing
code is in show.c.

#
# $PchId: TOUR,v 1.3 2006/03/31 11:33:46 philip Exp $
12 changes: 12 additions & 0 deletions bin/sh/USD.doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# $NetBSD: Makefile,v 1.1 2010/08/22 01:58:16 perry Exp $
# @(#)Makefile 8.1 (Berkeley) 8/14/93

DIR= usd/03.shell
SRCS= Rv7man t.mac t1 t2 t3 t4
MACROS= -ms

paper.ps: ${SRCS}
${TOOL_REFER} -e -p ${SRCS} | \
${TOOL_ROFF_PS} ${MACROS} > ${.TARGET}

.include <bsd.doc.mk>
Loading

0 comments on commit d90bee9

Please sign in to comment.