Changes for gsh version 2.0d8:

Fixed several mutual exclusion problems, including a particularly nasty
one that would cause gsh to loop forever inside the memory manager. (You
could identify this one by the "BRA (-23)" at the bottom of the infinite
loop.)

Fixed the string vector print routine to properly handle all numbers of
entries in the hash table.  Previously, it would always print duplicate
entries if there were < 6 commands hashed, and would sometimes print
duplicates (depending on previous contents of an internal table) for
other numbers of commands.

gsh would wait on background processes started from an exec file
(executed, not sourced). Now the exec file does not wait on the process,
but the background process is not associated with the parent shell after
the exec file terminates.

Made gsh globbing work more like csh: if none of the requested patterns
are found, print "No match" and exit.

At startup, if /etc/glogin, $HOME/glogin, or $HOME/gshrc does not exist,
don't report a "file not found" error message. (PR#100)
This commit is contained in:
tribby 1998-12-31 18:29:14 +00:00
parent bc56eb46eb
commit 6269a8ca25
17 changed files with 516 additions and 229 deletions

View File

@ -1,4 +1,4 @@
Last updated: Dec. 18, 1998 By: Dave Tribby Last updated: Dec. 27, 1998 By: Dave Tribby
For more bug reports, see http://www.gno.org/~gno/bugs.html For more bug reports, see http://www.gno.org/~gno/bugs.html
@ -18,10 +18,6 @@ When a background process finishes and there's text in the input buffer,
the next keypress correctly reprints the edit line but the key itself does the next keypress correctly reprints the edit line but the key itself does
not get put in the buffer. not get put in the buffer.
Running a process in the background from inside a script (not 'source',
but executing the script as a command) causes the shell to wait for that
background process to end - not exactly what we want.
Gsh requires the v2.0.4 ltermcap to link. A new version of the termcap Gsh requires the v2.0.4 ltermcap to link. A new version of the termcap
library is proposed for GNO v2.0.6, and gsh may require updates. library is proposed for GNO v2.0.6, and gsh may require updates.

View File

@ -1,6 +1,56 @@
GSH 2.0 UPDATES GSH 2.0 UPDATES
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Dec 30 98 [dmt] Added mutual exclusion to ~NEW and ~DISPOSE macros. Lack
of mutex could cause one fork to modify a memory table while
another fork was searching it, leaving one or both processes
in an infinite loop. This caused some recoding in nullfree
(shellutil.mac), since we have to unlock the mutex after
calling ~DISPOSE but before returning to the caller.
Dec 29 98 [dmt] For some sizes of the hash table, the hash command
would sometimes print an entry more than once. Made 2 changes
to sv_colprint (in sv.asm): 1) Ensure the number of columns is
never > number of entries. This is only a problem when there are
fewer than 6 files hashed. 2) Never look beyond the number of
entries stored in offtbl. Results could be affected by the
previous call to sv_colprint.
Dec 28 98 [dmt] Review code for mutual exclusion requirements.
= Change jsl to builtin subroutine near "foundit" in builtin.asm
into stack setup followed by rts, so that mutex is not required
to protect the setup and execution of the invocation.
= Add AliasMutex to protect data used by alias and unalias
commands (alias.asm)
= Remove pwdmutex from pwd command (builtin.asm).
= Remove mutex from dotods routine (dir.asm).
= Add DirMutex (for DirData) to dirs, pushd, and popd commands
(dir.asm).
= Add offtblmutex to sv_colprint routine (sv.asm).
= Change ErrorGS and SetGS calls so that parameter blocks are
on the stack for ShellExec (cmd.asm).
= Add lock/unlock of hashmutex to search routine so that the
hash function is protected. (hash.asm)
Dec 27 98 [dmt] Running a process in the background from inside a
script (not 'source', but executing the script as a command)
caused the script to wait for that background process to end.
Caused the script to run without waiting by checking for
background processing near beginning of "infork" (invoke.asm).
Because the parent process is the script, not gsh, when control
returns to gsh the script has terminated and the parent process
ID is 1 (null process). gsh cannot use its normal job control
commands, except "kill <pid>" (not "kill %<job>") works.
Dec 26 98 [dmt] Make gsh globbing work more like csh: if none of the
requested patterns are found, print "No match" and exit.
Dec 23 98 [dmt] At startup, if /etc/glogin, $HOME/glogin, or $HOME/gshrc
does not exist, skip "file not found" error message. (PR#100)
Dec 21 98 [dmt] Changes to this point checked-in to master archive.
Released as version 2.0d7
Dec 20 98 [dmt] For calls to system(), if input pointer is null or Dec 20 98 [dmt] For calls to system(), if input pointer is null or
lower level routines detect an error, return -1. This change lower level routines detect an error, return -1. This change
caused change to internal routine execute(): return -1 rather caused change to internal routine execute(): return -1 rather

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: alias.asm,v 1.7 1998/12/21 23:57:04 tribby Exp $ * $Id: alias.asm,v 1.8 1998/12/31 18:29:11 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -69,6 +69,8 @@ VTABSIZE gequ 17
alias START alias START
using AliasData
arg equ 1 arg equ 1
space equ arg+4 space equ arg+4
argc equ space+3 argc equ space+3
@ -84,6 +86,7 @@ end equ argv+4
phd phd
tcd tcd
lock AliasMutex
lda argc How many arguments were provided? lda argc How many arguments were provided?
dec a dec a
beq showall None -- show all alias names. beq showall None -- show all alias names.
@ -210,7 +213,8 @@ setit pei (arg+2)
pei (arg) pei (arg)
jsl nullfree jsl nullfree
exit lda space exit unlock AliasMutex
lda space
sta end-3 sta end-3
lda space+1 lda space+1
sta end-2 sta end-2
@ -240,11 +244,15 @@ spacestr dc c' ',h'00'
unalias START unalias START
using AliasData
status equ 0 status equ 0
space equ status+2 space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
lock AliasMutex
stz status stz status
lda argc lda argc
@ -270,7 +278,8 @@ loop add2 argv,#4,argv
bra loop bra loop
done return 2:status done unlock AliasMutex
return 2:status
Usage dc c'Usage: unalias name ...',h'0d00' Usage dc c'Usage: unalias name ...',h'0d00'
@ -539,7 +548,7 @@ replace ldy #8+2
pei (tmp+2) pei (tmp+2)
pei (tmp) pei (tmp)
jsr copycstr jsr copycstr
bra done jmp done
notfound ph4 #4*3 notfound ph4 #4*3
~NEW ~NEW
@ -842,6 +851,7 @@ AliasData DATA
AliasNum dc i2'0' AliasNum dc i2'0'
AliasPtr dc i4'0' AliasPtr dc i4'0'
AliasMutex key
AliasTable ds VTABSIZE*4 AliasTable ds VTABSIZE*4

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: builtin.asm,v 1.8 1998/12/21 23:57:04 tribby Exp $ * $Id: builtin.asm,v 1.9 1998/12/31 18:29:11 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -117,20 +117,32 @@ loop ldy #2
bpl done bpl done
add2 tbl,#10,tbl add2 tbl,#10,tbl
bra loop bra loop
;
foundit ldy #4 ; Found the command handler address. Since we don't have a "jsl [tbl],y"
lda [tbl],y ; instruction, after pushing parameters on the stack we will push the
sta ourproc+1 ; return address, then the command's address - 1 (2 bytes only, since it's
iny ; in the current bank). An rts will take us to the command handler, and a
lda [tbl],y ; rtl at the end of the handler will bring us back.
sta ourproc+2 ;
foundit anop
pei (argv+2) pei (argv+2) Push parameters (3 words)
pei (argv) pei (argv)
pei (argc) pei (argc)
ourproc jsl >$FFFFFF ;might want to mutex this!!!!!! phk Push return address (high byte)
sta val Save return status. per return-1 Push return address (low bytes)
ldy #4 Get address of builtin handler
lda [tbl],y (16 bytes; assume in this bank)
dec a subtract 1 so rts will take us there
pha
rts Go to builtin handler routine.
;
; Return from handler to this location
;
return sta val Save return status.
;
; Free the argv array
;
ph4 #0 (no path) ph4 #0 (no path)
pei (argc) pei (argc)
pei (argv+2) pei (argv+2)
@ -727,9 +739,7 @@ end equ argv+4
ldy #1 Return status = 1. ldy #1 Return status = 1.
bra exit bra exit
wait lock pwdmutex wait pea 0
pea 0
jsl getpfxstr Get value of prefix 0. jsl getpfxstr Get value of prefix 0.
sta ptr sta ptr
stx ptr+2 stx ptr+2
@ -752,8 +762,7 @@ doputs jsr puts Print the c-string
freebuf ph4 ptr Free the buffer. freebuf ph4 ptr Free the buffer.
jsl nullfree jsl nullfree
done unlock pwdmutex done ldy #0 Return status = 0.
ldy #0 Return status = 0.
exit lda space Deallocate stack space exit lda space Deallocate stack space
sta end-3 and return to the caller. sta end-3 and return to the caller.
@ -769,8 +778,6 @@ exit lda space Deallocate stack space
rtl rtl
pwdmutex key
Usage dc c'Usage: pwd',h'0d00' Usage dc c'Usage: pwd',h'0d00'
END END
@ -883,7 +890,7 @@ foundhash sta sptr
; ;
; It must be in the current prefix, so check it out. ; It must be in the current prefix, so check it out.
; ;
thispfx lock pwdmutex thispfx lock whichmutex
; ;
; check for existence of file ; check for existence of file
; ;
@ -938,7 +945,7 @@ freebuf ph4 ptr Free the buffer.
nofile ldx #^cantdoit nofile ldx #^cantdoit
lda #cantdoit lda #cantdoit
jsr puts jsr puts
donecwd unlock pwdmutex donecwd unlock whichmutex
pei (ptr+2) pei (ptr+2)
pei (ptr) pei (ptr)
jsl nullfree jsl nullfree
@ -968,7 +975,7 @@ builtstr dc c'Shell Built-in Command',h'00'
cantdoit dc c'Command Not Found',h'00' cantdoit dc c'Command Not Found',h'00'
aliasstr dc c'Aliased as ',h'00' aliasstr dc c'Aliased as ',h'00'
pwdmutex key whichmutex key
GRec dc i'4' GRec dc i'4'
GRecPath ds 4 GRecPath ds 4
@ -1007,7 +1014,7 @@ end equ argv+4
phd phd
tcd tcd
lock mutex lock prefixmutex
stz status Clear return status. stz status Clear return status.
lda argc Get number of arguments. lda argc Get number of arguments.
@ -1187,7 +1194,7 @@ finish ph4 PRecPath Free the name string buffer.
; ;
; Exit through here if PRecPath wasn't used ; Exit through here if PRecPath wasn't used
; ;
done unlock mutex done unlock prefixmutex
ldy status ldy status
@ -1205,7 +1212,7 @@ done unlock mutex
rtl rtl
mutex key prefixmutex key
errorstr dc c'prefix: could not set prefix, pathname may not exist.' errorstr dc c'prefix: could not set prefix, pathname may not exist.'
dc h'0d00' dc h'0d00'

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: cmd.asm,v 1.8 1998/12/21 23:57:05 tribby Exp $ * $Id: cmd.asm,v 1.9 1998/12/31 18:29:12 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -850,7 +850,8 @@ RRec equ CRec+4
NRec equ RRec+4 NRec equ RRec+4
ORec equ NRec+4 ORec equ NRec+4
ptr equ ORec+4 ptr equ ORec+4
status equ ptr+4 sptr equ ptr+4
status equ sptr+2
space equ status+2 space equ status+2
jobflag equ space+3 jobflag equ space+3
argv equ jobflag+2 argv equ jobflag+2
@ -879,10 +880,10 @@ parmloop lda count Get index
asl2 a into address array. asl2 a into address array.
tay tay
lda [argv],y Copy argument lda [argv],y Copy argument
sta SetValue pointer to sta ptr pointer to
iny2 SetValue iny2 ptr.
lda [argv],y lda [argv],y
sta SetValue+2 sta ptr+2
lda count If parameter number lda count If parameter number
cmp #10 cmp #10
@ -904,15 +905,31 @@ digits3 ldx #3 length = 3
setit stx pname setit stx pname
Int2Dec (@a,#pname_text,pname,#0) Int2Dec (@a,#pname_text,pname,#0)
;
; Build parameter block on stack and call SetGS (p 427 in ORCA/M manual)
;
set_value anop set_value anop
ph4 SetValue Convert value string tsx Save current stack pointer.
jsr c2gsstr to a GS/OS string stx sptr
stx SetValue+2 and save in SetGS pea 0 Export flag
sta SetValue parameter block. ph4 ptr Convert value string
jsr c2gsstr to a GS/OS string.
stx ptr+2 (Save for later
sta ptr deallocation).
phx
pha
ph4 #pname Address of variable name.
pea 3 Number of parameters
tsc Calculate Param Block addr
inc a (stack ptr + 1)
pea 0 and push 32 bits
pha onto stack
pea $0146 SetGS call number
jsl $E100B0 Call GS/OS
lda sptr Restore stack pointer.
tcs
SetGS SetPB Set $count to the argv string. ph4 ptr Free the value buffer.
ph4 SetValue Free the value buffer.
jsl nullfree jsl nullfree
inc count Bump the parameter counter. inc count Bump the parameter counter.
lda count If more to do, lda count If more to do,
@ -980,9 +997,29 @@ vars_set unlock mutex
jsl $E100B0 jsl $E100B0
bcc ok If there was an error, bcc ok If there was an error,
sta ErrError print a message cmp #$46 and it's not "file not found"
ErrorGS Err bne openerr on glogin or gshrc,
jmp done ldx jobflag
bmi godone
;
; Error opening source file. Assemble parameter block on stack and call
; ErrorGS (p 393 in ORCA/M manual)
;
openerr anop
tsx Save current stack pointer.
stx sptr
pha Push error number
pea 1 Push number of parameters
tsc Calculate PB addr
inc a (stack ptr + 1)
pea 0 and push 32 bits
pha onto stack
pea $0145 ErrorGS call number
jsl $E100B0 Call GS/OS
lda sptr Restore stack pointer.
tcs
godone jmp done
ok ldy #2 Copy file ref num ok ldy #2 Copy file ref num
lda [ORec],y from OpenGS PB into lda [ORec],y from OpenGS PB into
@ -1017,8 +1054,19 @@ ok ldy #2 Copy file ref num
jsl $E100B0 jsl $E100B0
bcc ok2 If there was an error, bcc ok2 If there was an error,
sta ErrError print a message tsx Save current stack pointer.
ErrorGS Err stx sptr
pha
pea 1
tsc
inc a
pea 0
pha
pea $0145
jsl $E100B0 Call ErrorGS to print a message
lda sptr Restore stack pointer.
tcs
jmp close_ex jmp close_ex
; ;
@ -1073,7 +1121,9 @@ noecho lda [data] If first character
* call execute: subroutine (4:cmdline,2:jobflag) * call execute: subroutine (4:cmdline,2:jobflag)
pei (data+2) pei (data+2)
pei (data) pei (data)
pei (jobflag) lda jobflag Remove "startup" flag bit
and #$7FFF from jobflag before passing it.
pha
jsl execute jsl execute
sta status sta status
@ -1131,19 +1181,6 @@ exit1a anop
NLTable dc h'0d' Newline Table NLTable dc h'0d' Newline Table
; Parameter block for shell ErrorGS call (p 393 in ORCA/M manual)
Err dc i2'1' pCount
ErrError ds 2 Error number
;
; Parameter block for shell SetGS calls (p 427 in ORCA/M manual)
;
SetPB anop
dc i2'3' pCount
SetName dc i4'pname' Name (pointer to GS/OS string)
SetValue ds 4 Value (pointer to GS/OS string)
SetExport ds 2 Export flag
; ;
; Name of argv parameter ($1 to $999) to be set; GS/OS string ; Name of argv parameter ($1 to $999) to be set; GS/OS string
; ;
@ -1323,8 +1360,16 @@ expand anop
sta ptr_glob sta ptr_glob
stx ptr_glob+2 stx ptr_glob+2
; Was there a globbing error?
ora ptr_glob+2
bne expalias
pha Put null pointer
pha on stack
jmp errexit and go to error exit.
; Expand aliases in the modified command line (final expansion) ; Expand aliases in the modified command line (final expansion)
phx expalias phx
lda ptr_glob
pha pha
jsl expandalias jsl expandalias
sta exebuf sta exebuf
@ -1405,7 +1450,8 @@ chkpid lda pid Get child process id.
cmp #-1 If -1 (error), all done. cmp #-1 If -1 (error), all done.
jeq errexit jeq errexit
lda jobflag If jobflag is set, if2 term,eq,#T_AMP,jobwait If last token was "&"
lda jobflag or jobflag is set,
beq jobwait do more complicated wait. beq jobwait do more complicated wait.
; ;
@ -1492,6 +1538,7 @@ donewait if2 term,eq,#T_EOF,endcmd If last token was EOF
; ;
errexit lda #-1 errexit lda #-1
sta waitstatus sta waitstatus
jsr setstatus Set process's $status.
; ;
; We have completed processing of a command ; We have completed processing of a command

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: dir.asm,v 1.8 1998/12/21 23:57:05 tribby Exp $ * $Id: dir.asm,v 1.9 1998/12/31 18:29:12 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -84,6 +84,8 @@ space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
lock DirMutex
stz status stz status
lda argc lda argc
dec a dec a
@ -121,7 +123,8 @@ showshort jsl dotods Set top of stack to current directory.
pea 1 pea 1
jsl showdir jsl showdir
exit return 2:status exit unlock DirMutex
return 2:status
usingstr dc c'usage: dirs [-l]',h'0d00' usingstr dc c'usage: dirs [-l]',h'0d00'
@ -149,6 +152,7 @@ space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
lock DirMutex
stz status stz status
lda argc Get number of arguments. lda argc Get number of arguments.
dec a If no parameters, dec a If no parameters,
@ -312,7 +316,8 @@ done lda varpushdsil If $PUSHDSILENT not defined,
pea 1 pea 1
jsl showdir show the directory stack. jsl showdir show the directory stack.
exit return 2:status exit unlock DirMutex
return 2:status
usagestr dc c'usage: pushd [+n | dir]',h'0d00' usagestr dc c'usage: pushd [+n | dir]',h'0d00'
err1 dc c'pushd: No other directory',h'0d00' err1 dc c'pushd: No other directory',h'0d00'
@ -344,6 +349,7 @@ space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
lock DirMutex
stz status stz status
lda argc lda argc
dec a dec a
@ -448,7 +454,8 @@ gototop lda tods
pea 1 pea 1
jsl showdir jsl showdir
exit return 2:status exit unlock DirMutex
return 2:status
usingstr dc c'Usage: popd [+n]',h'0d00' usingstr dc c'Usage: popd [+n]',h'0d00'
err1 dc c'popd: Directory stack empty',h'0d00' err1 dc c'popd: Directory stack empty',h'0d00'
@ -615,9 +622,7 @@ space equ idx+2
pha pha
jsl nullfree free it. jsl nullfree free it.
setit lock mutex setit pea 0
pea 0
jsl getpfxstr Get value of prefix 0. jsl getpfxstr Get value of prefix 0.
sta p sta p
stx p+2 stx p+2
@ -656,11 +661,7 @@ ok clc Source is result
lda p+2 lda p+2
sta dirstack+2,y sta dirstack+2,y
done unlock mutex done return
return
mutex key
END END
@ -674,6 +675,7 @@ DirData DATA
dirstack ds MAXD*4 dirstack ds MAXD*4
tods dc i'0' tods dc i'0'
DirMutex key
END END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: edit.asm,v 1.9 1998/12/21 23:57:06 tribby Exp $ * $Id: edit.asm,v 1.10 1998/12/31 18:29:12 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -1356,7 +1356,7 @@ q equ 4 locations.
beq eq_endhash beq eq_endhash
mv4 hash_table,p mv4 hash_table,p
lda hash_numexe lda hash_numexe
beq endhash jeq endhash
ldy #0 ldy #0
ldx t_size ldx t_size
eq_endhash beq endhash eq_endhash beq endhash
@ -1644,7 +1644,7 @@ space equ len+2
loop lda len loop lda len
jeq done jeq done
dec a dec a
beq putit ;last char in string jeq putit ;last char in string
lda [keystr] lda [keystr]
and #$FF and #$FF

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: expand.asm,v 1.6 1998/09/08 16:53:08 tribby Exp $ * $Id: expand.asm,v 1.7 1998/12/31 18:29:13 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -48,38 +48,40 @@ shallweglob equ filesep+2
wordbuf equ shallweglob+2 wordbuf equ shallweglob+2
ptr equ wordbuf+4 ptr equ wordbuf+4
buf equ ptr+4 buf equ ptr+4
space equ buf+4 globflag equ buf+4
space equ globflag+2
subroutine (4:cmd),space subroutine (4:cmd),space
;
; Check for noglob variable and exit if it's set to something.
;
lda varnoglob
beq doglob
; Allocate a buffer, copy the command line into it, and return. ; Allocate buffer to hold result
jsl alloc1024 jsl alloc1024
sta buf sta buf
stx buf+2 stx buf+2
; Check for noglob variable and exit if it's set to something.
ldy varnoglob
beq doglob
; Allocate a buffer, copy the command line into it, and return.
pei (cmd+2) pei (cmd+2)
pei (cmd) pei (cmd)
pei (buf+2) pei (buf+2)
pei (buf) pei (buf)
jsr copycstr jsr copycstr
jmp bye jmp bye
; ;
; noglob isn't set, so now we can actually start. ; noglob isn't set, so we can start globbing.
; ;
doglob jsl alloc1024 Create an output buffer. doglob sta ptr ptr points to next
sta buf
stx buf+2
sta ptr ptr points to next
stx ptr+2 position in buf. stx ptr+2 position in buf.
jsl alloc1024 Create a word buffer. jsl alloc1024 Create a word buffer.
sta wordbuf sta wordbuf
stx wordbuf+2 stx wordbuf+2
stz globflag globflag = no globbing done (yet).
; ;
; Find the beginning of the next word ; Find the beginning of the next word
; ;
@ -358,33 +360,48 @@ nomore anop
lda exppath lda exppath
jsl free1024 jsl free1024
lda count If somehing was expanded, lda count If something was expanded,
jne findword go find the next word. beq nothingfound
lda globflag Set "globbed, something found"
ora #$8000 bit in globflag.
sta globflag
jmp findword Go find the next word.
; Nothing was expanded from the wildcard. If we wanted to act like ; Nothing was expanded from the wildcard. If we wanted to act like
; ksh, we could pass the original text by doing a "jmp skipdeglob". ; ksh, we could pass the original text by doing a "jmp skipdeglob".
; Since passing a bad filename can mess up some programs, we will
; print an error message for this name and continue processing others.
ldx #^nomatch nothingfound anop
lda #nomatch lda globflag Set "globbed, nothing found"
jsr errputs ora #$4000 bit in globflag.
sta globflag
ldx wordbuf+2
lda wordbuf
jsr errputs
ldx #^ignored
lda #ignored
jsr errputs
jmp findword Go find the next word. jmp findword Go find the next word.
; ;
; Goodbye, cruel world, I'm leaving you today, Goodbye, goodbye. ; Goodbye, cruel world, I'm leaving you today, Goodbye, goodbye.
; ;
alldone jsr g_putbyte alldone jsr g_putbyte Store null byte at end of string.
ldx wordbuf+2
;
; Check globflag for no valid matches found in any pattern
;
lda globflag
cmp #$4000
bne alldone2
ldx #^nomatch
lda #nomatch
jsr errputs
ldx buf+2
lda buf
jsl free1024
stz buf+2
stz buf
alldone2 ldx wordbuf+2
lda wordbuf lda wordbuf
jsl free1024 jsl free1024
@ -443,8 +460,7 @@ InitWCPath ds 4 Path name, with wildcard
nWCparm dc i2'1' pCount nWCparm dc i2'1' pCount
nWCname ds 4 Pointer to returned path name nWCname ds 4 Pointer to returned path name
nomatch dc c'No match: ',h'00' nomatch dc c'No match',h'0d00'
ignored dc c' ignored',h'0d00'
END END

View File

@ -6,38 +6,6 @@
* ^ ^ ^ ^ ^ ^ * ^ ^ ^ ^ ^ ^
************************************************************************** **************************************************************************
; ------------------
; Mutual Exclusion
; ------------------
********************
* key
********************
MACRO
&lab key
&lab dc i2'0'
MEND
********************
* lock
********************
MACRO
&lab lock &a1
&lab lda #1
tsb &a1
beq *+6
cop $7F
bra *-7
MEND
********************
* unlock
********************
MACRO
&lab unlock &a1
&lab stz &a1
MEND
; ------------------ ; ------------------
; GNO/ME subroutine calls ; GNO/ME subroutine calls
; ------------------ ; ------------------
@ -1960,7 +1928,14 @@ skip&syscnt anop
MACRO MACRO
&lab ~NEW &lab ~NEW
&lab anop &lab anop
* -- Portion needed for debug version
* jsl DB~NEW
*
* -- Rest is for non-debug version
using memglobal
lock memmutex
jsl ~NEW jsl ~NEW
unlock memmutex
MEND MEND
@ -1970,5 +1945,44 @@ skip&syscnt anop
MACRO MACRO
&lab ~DISPOSE &lab ~DISPOSE
&lab anop &lab anop
jml ~DISPOSE * -- Portion needed for debug version
* jsl DB~DISPOSE
*
* -- Rest is for non-debug version
using memglobal
lock memmutex
jsl ~DISPOSE
unlock memmutex
MEND
; ------------------
; Mutual Exclusion
; ------------------
********************
* key
********************
MACRO
&lab key
&lab dc i2'0'
MEND
********************
* lock
********************
MACRO
&lab lock &a1
&lab lda #1
tsb &a1
beq *+6
cop $7F
bra *-7
MEND
********************
* unlock
********************
MACRO
&lab unlock &a1
&lab stz &a1
MEND MEND

View File

@ -1,7 +1,7 @@
/* /*
* Resources for version and comment * Resources for version and comment
* *
* $Id: gsh.rez,v 1.9 1998/12/22 16:05:32 gdr-ftp Exp $ * $Id: gsh.rez,v 1.10 1998/12/31 18:29:13 tribby Exp $
*/ */
#define PROG "gsh" #define PROG "gsh"
@ -16,7 +16,7 @@
resource rVersion (1, purgeable3) { resource rVersion (1, purgeable3) {
{ 2, 0, 0, /* Version 2.0.0 */ { 2, 0, 0, /* Version 2.0.0 */
development, /* development|alpha|beta|final|release */ development, /* development|alpha|beta|final|release */
7 }, /* non-final release number */ 8 }, /* non-final release number */
verUS, /* Country */ verUS, /* Country */
PROG, /* Program name */ PROG, /* Program name */
DESC DESC

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: hash.asm,v 1.7 1998/12/21 23:57:06 tribby Exp $ * $Id: hash.asm,v 1.8 1998/12/31 18:29:13 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -98,24 +98,33 @@ num equ space+2
name equ num+2 name equ num+2
end equ name+4 end equ name+4
* NOTE: hash should only be called after hashmutex is locked
;
; No local variables; just need to save old Dir Page pointer and set
; up new one to point to parameters.
;
tsc tsc
phd phd
tcd tcd
lda num lda num If this isn't the first time
bne hasher bne hasher through, reuse the value of "h".
;
; First time through for the name: calculate value for "h"
;
stz h stz h
ldy #0 ldy #0
loop lda [name],y loop lda [name],y
and #$FF and #$FF
beq hasher beq hasher
sta addit+1 sta addit+1 Modify "adc #$FFFF"
lda h ;left shift 7 lda h ;left shift 7
xba xba
and #$FF00 and #$FF00
lsr a lsr a
addit adc #0 ;(cf=0) addit adc #$FFFF NOTE: immediate data was modified.
phy phy
UDivide (@a,t_size),(@a,@a) UDivide (@a,t_size),(@a,@a)
sta h sta h
@ -123,6 +132,9 @@ addit adc #0 ;(cf=0)
iny iny
bra loop bra loop
;
; "h" has been calculated; now do the rest of the hash function
;
hasher lda num ;num*num hasher lda num ;num*num
sta tmp sta tmp
lda #0 lda #0
@ -139,7 +151,7 @@ nomul dex
asl a asl a
asl a asl a
sec sec
sbc 1,s sbc 1,s (Use top word on stack as temp var)
asl a asl a
asl a asl a
adc 1,s adc 1,s
@ -154,9 +166,12 @@ nomul dex
adc h adc h
sec sec
sbc num sbc num
plx plx (Remove temp var from stack)
UDivide (@a,t_size),(@a,@y) UDivide (@a,t_size),(@a,@y)
;
; Return the hashed value to the user
;
lda space lda space
sta end-2 sta end-2
pld pld
@ -165,10 +180,10 @@ nomul dex
adc #end-3 adc #end-3
tcs tcs
tya tya Final hash value is in accumulator.
rts rts
h ds 2 h ds 2 NOTE: h must be a "static" variable.
tmp ds 2 tmp ds 2
END END
@ -360,6 +375,8 @@ done anop
search START search START
using hashdata
ptr equ 1 ptr equ 1
name_len equ ptr+4 name_len equ ptr+4
full_path equ name_len+2 full_path equ name_len+2
@ -379,6 +396,8 @@ end equ file+4
phd phd
tcd tcd
lock hashmutex
stz qh stz qh
stz full_path Set result to NULL. stz full_path Set result to NULL.
stz full_path+2 stz full_path+2
@ -468,7 +487,9 @@ found lda [ptr]
pha pha
jsr copycstr Put filename at end of pathname. jsr copycstr Put filename at end of pathname.
done ldx full_path+2 Load return value into Y- & X- regs done unlock hashmutex
ldx full_path+2 Load return value into Y- & X- regs
ldy full_path ldy full_path
; Adjust stack in preparation for return ; Adjust stack in preparation for return
@ -572,6 +593,9 @@ ptr equ numEntries+2
space equ ptr+4 space equ ptr+4
subroutine (4:dir,2:dirNum,4:files),space subroutine (4:dir,2:dirNum,4:files),space
* NOTE: dir_search is only called from hashpath (after hashmutex locked)
; ;
; Open directory name passed as 1st parameter ; Open directory name passed as 1st parameter
; ;
@ -731,6 +755,7 @@ hashpath START
using hashdata using hashdata
using vardata using vardata
using global
len equ 1 len equ 1
pathnum equ len+2 pathnum equ len+2
@ -1062,7 +1087,7 @@ filesdone anop
ph4 gsosbuf Free memory allocated for ph4 gsosbuf Free memory allocated for
jsl nullfree $PATH string. jsl nullfree $PATH string.
lda hash_print If initialization isn't complete, lda done_init If initialization isn't complete,
beq noprint don't print the # of files. beq noprint don't print the # of files.
Int2Dec (hash_numexe,#hashnum,#3,#0) Int2Dec (hash_numexe,#hashnum,#3,#0)
@ -1090,8 +1115,6 @@ noprint anop
rtl rtl
hashmutex key Mutual exclusion key
pathname gsstr 'path' pathname gsstr 'path'
hashmsg dc c'hashed ' hashmsg dc c'hashed '
@ -1167,12 +1190,13 @@ done rts
hashdata DATA hashdata DATA
hashmutex key Mutual exclusion key
t_size ds 2 t_size = (TAB_MULT * numexe) - 1 t_size ds 2 t_size = (TAB_MULT * numexe) - 1
hash_paths dc 32i4'0' 32 paths max for now. hash_paths dc 32i4'0' 32 paths max for now.
hash_files dc i4'0' hash_files dc i4'0'
hash_table dc i4'0' Pointer to table (t_size entries) hash_table dc i4'0' Pointer to table (t_size entries)
hash_numexe dc i2'0' Number of hashed executables hash_numexe dc i2'0' Number of hashed executables
hash_print dc i2'0' Print flag; 0 until init is complete
END END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: invoke.asm,v 1.9 1998/12/21 23:57:06 tribby Exp $ * $Id: invoke.asm,v 1.10 1998/12/31 18:29:13 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -73,6 +73,8 @@ end equ sfile+4
; subroutine (4:sfile,4:dfile,4:efile,2:app,2:eapp,2:pipein,2:pipeout,2:pipein2,2:pipeout2),space ; subroutine (4:sfile,4:dfile,4:efile,2:app,2:eapp,2:pipein,2:pipeout,2:pipein2,2:pipeout2),space
* NOTE: only called from invoke, after fork_mutex is locked
tsc tsc
phd phd
tcd tcd
@ -672,7 +674,7 @@ prefork lock fork_mutex Lock the fork mutual exclusion.
; ;
; Tasks the parent process does right after forking ; Tasks the parent process does right after forking
; ;
postfork sta rtnval postfork sta rtnval Save pid as return value.
lda pipein If pipein != 0, lda pipein If pipein != 0,
beq postfork2 beq postfork2
sta CloseRef sta CloseRef
@ -723,11 +725,18 @@ postfork6 rts
; ;
infork phk Make sure data bank register infork phk Make sure data bank register
plb is the same as program bank. plb is the same as program bank.
;
lda _jobflag If jobflag == 0, ; NOTE: next two lines were added for v2.0.6 in order to prevent background
; processes from being waited on when they are kicked off from an
; exec file. The side effect of having the process become owned by
; the null process may not be desired. (Perhaps there is a better way!)
;
lda _bg If in background
bne optty
lda _jobflag or jobflag == 0,
bne infork0b bne infork0b
Open ttyopen Open tty. optty Open ttyopen Open tty.
jcs errinfork jcs errinfork
lda _pipein lda _pipein
@ -735,7 +744,6 @@ infork phk Make sure data bank register
tcnewpgrp ttyref allocate new process group. tcnewpgrp ttyref allocate new process group.
infork0a settpgrp ttyref Set current process to have proc group. infork0a settpgrp ttyref Set current process to have proc group.
lda _bg If in background, lda _bg If in background,
and #$FF
beq infork0b beq infork0b
tctpgrp (gshtty,gshpid) reset tty to the shell process group. tctpgrp (gshtty,gshpid) reset tty to the shell process group.

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: jobs.asm,v 1.8 1998/12/21 23:57:06 tribby Exp $ * $Id: jobs.asm,v 1.9 1998/12/31 18:29:13 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -19,6 +19,40 @@
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65 * Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | | * | | | | | |
* ^ ^ ^ ^ ^ ^ * ^ ^ ^ ^ ^ ^
**************************************************************************
*
* Interfaces defined in this file:
*
* pwait no parameters wait for forground
*
* jobkiller no parameters kill all jobs
*
* palloc subroutine (2:pid,2:bg,4:cmd) alloc/fill proc struc
*
* pallocpipe subroutine (2:pid,2:bg,4:cmd) palloc+append to pipe
*
* pchild subroutine (2:code,2:signum) handle SIGCHLD
*
* removejentry subroutine (2:pid) Remove a job entry
* Return: A-reg = 1 if found, 0 if not found
*
* mkjobcur jsr with 1 address parameter
*
* jobs subroutine (4:argv,2:argc) built-in command
*
* kill subroutine (4:argv,2:argc) built-in command
*
* fg subroutine (4:argv,2:argc) built-in command
*
* bg subroutine (4:argv,2:argc) built-in command
*
* stop subroutine (4:argv,2:argc) built-in command
*
* pprint subroutine (4:pp,2:idflag,2:signum) print job entry
*
* parsepid subroutine (4:str) parse "%" pid
* return 2:pid
*
************************************************************************** **************************************************************************
mcopy /obj/gno/bin/gsh/jobs.mac mcopy /obj/gno/bin/gsh/jobs.mac
@ -894,7 +928,7 @@ done lda space,s
************************************************************************** **************************************************************************
* *
* JOBS: builtin command * JOBS: builtin command
* syntax: exit * syntax: jobs
* *
* displays jobs * displays jobs
* *
@ -914,18 +948,16 @@ space equ status+2
stz pidflag stz pidflag
stz status stz status
lda argc
dec a
beq cont
dec a
beq grab
shit ldx #^Usage
lda #Usage
jsr errputs
inc status Return status = 1.
jmp done
grab ldy #4 lda argc If no argument,
dec a
beq startcmd start processing.
dec a If > 1 argument,
bne prusage print usage string.
;
; Argument provided. It had better be "-l\0"
;
ldy #4
lda [argv],y lda [argv],y
sta pp sta pp
ldy #4+2 ldy #4+2
@ -933,40 +965,62 @@ grab ldy #4
sta pp+2 sta pp+2
lda [pp] lda [pp]
and #$FF and #$FF
if2 @a,ne,#'-',shit if2 @a,ne,#'-',prusage
ldy #1 ldy #1
lda [pp],y lda [pp],y
if2 @a,ne,#'l',shit if2 @a,eq,#'l',optset
inc pidflag ;
; Error with command line
;
prusage ldx #^Usage Print usage string.
lda #Usage
jsr errputs
inc status Return status = 1.
jmp done
cont ld2 1,count ;
; "-l" option set
;
optset inc pidflag
;
; Start processing "jobs" command
;
startcmd ld2 1,count count = 1.
;
; Outer loop: scan the job list
;
loop lda pjoblist loop lda pjoblist
ldx pjoblist+2 ldx pjoblist+2
;
; Inner loop: find entry in job list that matches the count number.
;
loop2 sta pp loop2 sta pp
stx pp+2 stx pp+2
ora pp+2 ora pp+2 If at end of list,
beq next beq next there was no entry with this count!
ldy #p_index ldy #p_index If p_index field
lda [pp],y lda [pp],y in this entry
cmp count cmp count matches count,
beq gotit beq gotit go print the contents.
ldy #p_next+2 ldy #p_next+2 Otherwise,
lda [pp],y lda [pp],y point to next entry in list.
tax tax
ldy #p_next ldy #p_next
lda [pp],y lda [pp],y
bra loop2 bra loop2
gotit pei (pp+2) gotit pei (pp+2) Push address of entry,
pei (pp) pei (pp)
pei (pidflag) pei (pidflag) "long" flag,
pea 0 pea 0 (signum = 0)
jsl pprint jsl pprint and print the entry.
next inc count next inc count Bump count.
lda count lda count
cmp pmaxindex cmp pmaxindex If more to be printed,
beq loop beq loop scan list for next entry.
bcc loop bcc loop
done return 2:status done return 2:status

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: orca.asm,v 1.7 1998/12/21 23:57:07 tribby Exp $ * $Id: orca.asm,v 1.8 1998/12/31 18:29:14 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -19,6 +19,12 @@
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65 * Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | | * | | | | | |
* ^ ^ ^ ^ ^ ^ * ^ ^ ^ ^ ^ ^
**************************************************************************
*
* Interfaces defined in this file:
*
* edit subroutine (4:argv,2:argc) builtin command
*
************************************************************************** **************************************************************************
mcopy /obj/gno/bin/gsh/orca.mac mcopy /obj/gno/bin/gsh/orca.mac

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: shell.asm,v 1.8 1998/12/21 23:57:07 tribby Exp $ * $Id: shell.asm,v 1.9 1998/12/31 18:29:14 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -63,7 +63,6 @@ shell start
using pdata using pdata
using HistoryData using HistoryData
using termdata using termdata
using hashdata
p equ 0 General pointer p equ 0 General pointer
cflag equ p+4 Flag: set when path converted cflag equ p+4 Flag: set when path converted
@ -186,7 +185,8 @@ nopathconv anop
pha argc = 0 pha argc = 0
pha argv = NULL pha argv = NULL
pha pha
pha jobflag = 0 lda #$8000
pha jobflag = $8000
jsl ShellExec jsl ShellExec
; Read and execute $HOME/glogin ; Read and execute $HOME/glogin
@ -209,7 +209,7 @@ fastskip2 anop
didit anop didit anop
jsr dispose_hash Remove old table (if set in jsr dispose_hash Remove old table (if set in
jsl hashpath login files) and hash $PATH. jsl hashpath login files) and hash $PATH.
ld2 1,hash_print Set hash print flag. ld2 1,done_init Set initialization done flag.
; ;
; Check for command-line arguments -c and -e ; Check for command-line arguments -c and -e
@ -385,7 +385,8 @@ no_ovf phx
pha argc = 0 pha argc = 0
pha argv = NULL pha argv = NULL
pha pha
pha jobflag = 0 lda #$8000
pha jobflag = $8000
jsl ShellExec jsl ShellExec
; Dispose $HOME/gshrc string ; Dispose $HOME/gshrc string
@ -587,6 +588,7 @@ gshtty ds 2
gshpid ds 2 gshpid ds 2
exit_requested dc i'0' ;!=0 if exit exit_requested dc i'0' ;!=0 if exit
signalled dc i'0' signalled dc i'0'
done_init dc i2'0' 0 until init is complete
FastFlag dc i'0' FastFlag dc i'0'
CmdFlag dc i'0' CmdFlag dc i'0'

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: shellutil.asm,v 1.7 1998/12/21 23:57:08 tribby Exp $ * $Id: shellutil.asm,v 1.8 1998/12/31 18:29:14 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -479,19 +479,39 @@ done ldx new+2
nullfree START nullfree START
lda 4,s lda 4,s Hold address
ora 6,s tay parameter in
bne ok lda 6,s X and Y registers.
lda 2,s tax
sta 6,s lda 2,s Move return
lda 1,s sta 6,s address on
lda 1,s the stack.
sta 5,s sta 5,s
tya Put address
sta 1,s parameter back
txa on the stack.
sta 3,s
ora 1,s If address is NULL,
bne ok
plx clean up stack
plx plx
plx rtl and return to caller.
ok ~DISPOSE NOTE: macro locks/unlocks mem mutex
rtl rtl
ok ~DISPOSE END
;=====================================================================
;
; Data area that holds memory manager mutual exclusion key,
; which is referenced in the ~NEW and ~DISPOSE macros
;
;=====================================================================
memglobal DATA
memmutex key
END END
;===================================================================== ;=====================================================================

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: sv.asm,v 1.6 1998/09/08 16:53:14 tribby Exp $ * $Id: sv.asm,v 1.7 1998/12/31 18:29:14 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@ -19,6 +19,23 @@
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65 * Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
* | | | | | | * | | | | | |
* ^ ^ ^ ^ ^ ^ * ^ ^ ^ ^ ^ ^
**************************************************************************
*
* Interfaces defined in this file:
*
* sv_alloc subroutine (2:size)
* return 4:ptr
*
* sv_add subroutine (4:vect,4:string,2:allocflag)
*
* sv_dispose subroutine (4:vect)
*
* sv_colprint subroutine (4:sv)
*
* sv_sort subroutine (4:sv)
*
* _qsort subroutine (4:sv,2:left,2:right)
*
************************************************************************** **************************************************************************
mcopy /obj/gno/bin/gsh/sv.mac mcopy /obj/gno/bin/gsh/sv.mac
@ -233,19 +250,26 @@ nextlen pla
; a divide.. ; a divide..
; ;
ldx #0 ldx #0
txa lda maxlen
dex
clc clc
colloop inx colloop inx
adc maxlen adc maxlen
cmp #80 cmp #80
bcc colloop bcc colloop
cpx #6+1
bcc okcol cpx #6+1 Make sure there
ldx #6 ;limit of 6 columns bcc okcol are no more
ldx #6 than 6 columns.
okcol stx numcol okcol stx numcol
lda [base]
cmp numcol Ensure number of columns
bcs okcol2 <= number of entries
tax
stx numcol
okcol2 anop
; ;
; recalculate the width ; recalculate the width based upon columns/80
; ;
UDivide (#80,@x),(maxlen,@a) UDivide (#80,@x),(maxlen,@a)
; ;
@ -261,6 +285,7 @@ foocol anop
; ;
; find the index for each column... ; find the index for each column...
; ;
lock offtblmutex
lda #0 lda #0
tax tax
clc clc
@ -269,11 +294,12 @@ mkidxloop sta offtbl,x
adc numrow adc numrow
cmp [base] cmp [base]
bcc mkidxloop bcc mkidxloop
;
; well....I think we can print now (yay!) stx numcol Double numcol since it's compared
;
asl numcol Double numcol since it's compared
ldx #0 against X to end the loop. ldx #0 against X to end the loop.
;
; Ready to print...
;
printloop lda offtbl,x printloop lda offtbl,x
cmp [base] cmp [base]
bcs nextprint0 bcs nextprint0
@ -311,13 +337,16 @@ nextprint0 jsr newline
dec numrow dec numrow
bne printloop bne printloop
doneprint return unlock offtblmutex
return
; ;
; Offset table: one entry for each column ; Offset table: one entry for each column
; ;
offtbl ds 14 offtbl ds 14
offtblmutex key
END END
************************************************************************** **************************************************************************
@ -345,6 +374,8 @@ space equ 0
END END
**************************************************************************
_qsort PRIVATE _qsort PRIVATE
vleft equ 0 vleft equ 0