Skip to content

Commit

Permalink
rc: import latest from 9front
Browse files Browse the repository at this point in the history
Includes work to increase portability on *nix systems by cinap_lenrek,
some extensions to the syntax, and multiple bug fixes to:
 - lexer/interpreter
 - globber
 - heredoc
and much more.
  • Loading branch information
grobe0ba committed Aug 2, 2022
1 parent 964ac74 commit 90316f6
Show file tree
Hide file tree
Showing 33 changed files with 4,554 additions and 2,988 deletions.
47 changes: 17 additions & 30 deletions rcmain
Original file line number Diff line number Diff line change
@@ -1,51 +1,38 @@
# rcmain: Plan 9 on Unix version
# rcmain: unix version
if(~ $#home 0) home=$HOME
if(~ $#home 0) home=/
if(~ $#ifs 0) ifs='
'
profile=$home/.rcrc
switch($#prompt){
case 0
prompt=('% ' ' ')
case 1
prompt=($prompt ' ')
}
if(~ $rcname ?.out ?.rc */?.rc */?.out) prompt=('broken! ' ' ')
if(flag p) path=(/bin /usr/bin)
if not{
if(~ $rcname ?.out) prompt=('broken! ' ' ')
if(flag p) path=/bin
if not {
finit
# should be taken care of by rc now, but leave just in case
if(~ $#path 0) path=(. /bin /usr/bin /usr/local/bin)
}
fn sigexit
if(! ~ $#cflag 0){
if(flag l && test -r $home/lib/profile) . $home/lib/profile
if(flag l) {
. -q $profile
}
status=''
eval $cflag
exit $status
}
if(flag i){
if(~ $termprog 9term || ~ $termprog win){
fn cd {
# builtin cd $1 && flag i && awd
# is not sufficient when running in a subshell
# that is rc -e (like mk uses!)
if(builtin cd $1){
if(flag i) $PLAN9/bin/9 awd || status=''
status=''
}
}
$PLAN9/bin/9 awd
if not if(flag i){
if(flag l) {
. -q $profile
}
if(flag l && test -r $home/lib/profile) . $home/lib/profile
status=''
if(! ~ $#* 0) . $*
. -i '/dev/stdin'
exit $status
. -i /dev/fd/0
}
if(flag l && test -r $home/lib/profile) . $home/lib/profile
if(~ $#* 0){
. /dev/stdin
exit $status
if not if(~ $#* 0) . /dev/fd/0
if not{
status=''
. $*
}
status=''
. $*
exit $status
51 changes: 51 additions & 0 deletions src/cmd/rc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
TARG=rc

OFILES=\
code.o\
exec.o\
getflags.o\
glob.o\
here.o\
io.o\
lex.o\
pcmd.o\
pfnc.o\
simple.o\
subr.o\
trap.o\
tree.o\
var.o\
havefork.o\
unix.o\
syn.o\

HFILES=rc.h\
y.tab.h\
io.h\
exec.h\
fns.h\
getflags.h\

YFILES=syn.y
YFLAGS=-d

PREFIX=/usr/local

all: $(TARG)

install: $(TARG) rcmain.unix
cp $(TARG) $(PREFIX)/bin/
cp rcmain.unix $(PREFIX)/lib/rcmain

$(TARG): $(OFILES)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(TARG) $(OFILES)

y.tab.h: syn.c

unix.o: unix.c
$(CC) $(CFLAGS) '-DPREFIX="$(PREFIX)"' -c unix.c

$(OFILES): $(HFILES)

clean:
rm -f $(OFILES) $(TARG) syn.c y.tab.? y.debug
Loading

0 comments on commit 90316f6

Please sign in to comment.