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
@ -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
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
library is proposed for GNO v2.0.6, and gsh may require updates.

View File

@ -1,6 +1,56 @@
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
lower level routines detect an error, return -1. This change
caused change to internal routine execute(): return -1 rather

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
using AliasData
arg equ 1
space equ arg+4
argc equ space+3
@ -84,6 +86,7 @@ end equ argv+4
phd
tcd
lock AliasMutex
lda argc How many arguments were provided?
dec a
beq showall None -- show all alias names.
@ -210,7 +213,8 @@ setit pei (arg+2)
pei (arg)
jsl nullfree
exit lda space
exit unlock AliasMutex
lda space
sta end-3
lda space+1
sta end-2
@ -240,11 +244,15 @@ spacestr dc c' ',h'00'
unalias START
using AliasData
status equ 0
space equ status+2
subroutine (4:argv,2:argc),space
lock AliasMutex
stz status
lda argc
@ -270,7 +278,8 @@ loop add2 argv,#4,argv
bra loop
done return 2:status
done unlock AliasMutex
return 2:status
Usage dc c'Usage: unalias name ...',h'0d00'
@ -539,7 +548,7 @@ replace ldy #8+2
pei (tmp+2)
pei (tmp)
jsr copycstr
bra done
jmp done
notfound ph4 #4*3
~NEW
@ -842,6 +851,7 @@ AliasData DATA
AliasNum dc i2'0'
AliasPtr dc i4'0'
AliasMutex key
AliasTable ds VTABSIZE*4

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
add2 tbl,#10,tbl
bra loop
foundit ldy #4
lda [tbl],y
sta ourproc+1
iny
lda [tbl],y
sta ourproc+2
pei (argv+2)
;
; Found the command handler address. Since we don't have a "jsl [tbl],y"
; instruction, after pushing parameters on the stack we will push the
; return address, then the command's address - 1 (2 bytes only, since it's
; in the current bank). An rts will take us to the command handler, and a
; rtl at the end of the handler will bring us back.
;
foundit anop
pei (argv+2) Push parameters (3 words)
pei (argv)
pei (argc)
ourproc jsl >$FFFFFF ;might want to mutex this!!!!!!
sta val Save return status.
phk Push return address (high byte)
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)
pei (argc)
pei (argv+2)
@ -727,9 +739,7 @@ end equ argv+4
ldy #1 Return status = 1.
bra exit
wait lock pwdmutex
pea 0
wait pea 0
jsl getpfxstr Get value of prefix 0.
sta ptr
stx ptr+2
@ -752,8 +762,7 @@ doputs jsr puts Print the c-string
freebuf ph4 ptr Free the buffer.
jsl nullfree
done unlock pwdmutex
ldy #0 Return status = 0.
done ldy #0 Return status = 0.
exit lda space Deallocate stack space
sta end-3 and return to the caller.
@ -769,8 +778,6 @@ exit lda space Deallocate stack space
rtl
pwdmutex key
Usage dc c'Usage: pwd',h'0d00'
END
@ -883,7 +890,7 @@ foundhash sta sptr
;
; It must be in the current prefix, so check it out.
;
thispfx lock pwdmutex
thispfx lock whichmutex
;
; check for existence of file
;
@ -938,7 +945,7 @@ freebuf ph4 ptr Free the buffer.
nofile ldx #^cantdoit
lda #cantdoit
jsr puts
donecwd unlock pwdmutex
donecwd unlock whichmutex
pei (ptr+2)
pei (ptr)
jsl nullfree
@ -968,7 +975,7 @@ builtstr dc c'Shell Built-in Command',h'00'
cantdoit dc c'Command Not Found',h'00'
aliasstr dc c'Aliased as ',h'00'
pwdmutex key
whichmutex key
GRec dc i'4'
GRecPath ds 4
@ -1007,7 +1014,7 @@ end equ argv+4
phd
tcd
lock mutex
lock prefixmutex
stz status Clear return status.
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
;
done unlock mutex
done unlock prefixmutex
ldy status
@ -1205,7 +1212,7 @@ done unlock mutex
rtl
mutex key
prefixmutex key
errorstr dc c'prefix: could not set prefix, pathname may not exist.'
dc h'0d00'

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
ORec equ NRec+4
ptr equ ORec+4
status equ ptr+4
sptr equ ptr+4
status equ sptr+2
space equ status+2
jobflag equ space+3
argv equ jobflag+2
@ -879,10 +880,10 @@ parmloop lda count Get index
asl2 a into address array.
tay
lda [argv],y Copy argument
sta SetValue pointer to
iny2 SetValue
sta ptr pointer to
iny2 ptr.
lda [argv],y
sta SetValue+2
sta ptr+2
lda count If parameter number
cmp #10
@ -904,15 +905,31 @@ digits3 ldx #3 length = 3
setit stx pname
Int2Dec (@a,#pname_text,pname,#0)
;
; Build parameter block on stack and call SetGS (p 427 in ORCA/M manual)
;
set_value anop
ph4 SetValue Convert value string
jsr c2gsstr to a GS/OS string
stx SetValue+2 and save in SetGS
sta SetValue parameter block.
tsx Save current stack pointer.
stx sptr
pea 0 Export flag
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 SetValue Free the value buffer.
ph4 ptr Free the value buffer.
jsl nullfree
inc count Bump the parameter counter.
lda count If more to do,
@ -980,9 +997,29 @@ vars_set unlock mutex
jsl $E100B0
bcc ok If there was an error,
sta ErrError print a message
ErrorGS Err
jmp done
cmp #$46 and it's not "file not found"
bne openerr on glogin or gshrc,
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
lda [ORec],y from OpenGS PB into
@ -1017,8 +1054,19 @@ ok ldy #2 Copy file ref num
jsl $E100B0
bcc ok2 If there was an error,
sta ErrError print a message
ErrorGS Err
tsx Save current stack pointer.
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
;
@ -1073,7 +1121,9 @@ noecho lda [data] If first character
* call execute: subroutine (4:cmdline,2:jobflag)
pei (data+2)
pei (data)
pei (jobflag)
lda jobflag Remove "startup" flag bit
and #$7FFF from jobflag before passing it.
pha
jsl execute
sta status
@ -1131,19 +1181,6 @@ exit1a anop
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
;
@ -1323,8 +1360,16 @@ expand anop
sta ptr_glob
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)
phx
expalias phx
lda ptr_glob
pha
jsl expandalias
sta exebuf
@ -1405,8 +1450,9 @@ chkpid lda pid Get child process id.
cmp #-1 If -1 (error), all done.
jeq errexit
lda jobflag If jobflag is set,
beq jobwait do more complicated wait.
if2 term,eq,#T_AMP,jobwait If last token was "&"
lda jobflag or jobflag is set,
beq jobwait do more complicated wait.
;
; Uncomplicated wait: simply call wait() to get child's termination status
@ -1492,6 +1538,7 @@ donewait if2 term,eq,#T_EOF,endcmd If last token was EOF
;
errexit lda #-1
sta waitstatus
jsr setstatus Set process's $status.
;
; We have completed processing of a command

View File

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

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
mv4 hash_table,p
lda hash_numexe
beq endhash
jeq endhash
ldy #0
ldx t_size
eq_endhash beq endhash
@ -1644,7 +1644,7 @@ space equ len+2
loop lda len
jeq done
dec a
beq putit ;last char in string
jeq putit ;last char in string
lda [keystr]
and #$FF

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
ptr equ wordbuf+4
buf equ ptr+4
space equ buf+4
globflag equ buf+4
space equ globflag+2
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
sta buf
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)
pei (buf+2)
pei (buf)
jsr copycstr
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.
sta buf
stx buf+2
sta ptr ptr points to next
doglob sta ptr ptr points to next
stx ptr+2 position in buf.
jsl alloc1024 Create a word buffer.
sta wordbuf
stx wordbuf+2
stz globflag globflag = no globbing done (yet).
;
; Find the beginning of the next word
;
@ -358,33 +360,48 @@ nomore anop
lda exppath
jsl free1024
lda count If somehing was expanded,
jne findword go find the next word.
lda count If something was expanded,
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
; 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
lda #nomatch
jsr errputs
ldx wordbuf+2
lda wordbuf
jsr errputs
ldx #^ignored
lda #ignored
jsr errputs
nothingfound anop
lda globflag Set "globbed, nothing found"
ora #$4000 bit in globflag.
sta globflag
jmp findword Go find the next word.
;
; Goodbye, cruel world, I'm leaving you today, Goodbye, goodbye.
;
alldone jsr g_putbyte
ldx wordbuf+2
alldone jsr g_putbyte Store null byte at end of string.
;
; 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
jsl free1024
@ -443,8 +460,7 @@ InitWCPath ds 4 Path name, with wildcard
nWCparm dc i2'1' pCount
nWCname ds 4 Pointer to returned path name
nomatch dc c'No match: ',h'00'
ignored dc c' ignored',h'0d00'
nomatch dc c'No match',h'0d00'
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
; ------------------
@ -1960,7 +1928,14 @@ skip&syscnt anop
MACRO
&lab ~NEW
&lab anop
* -- Portion needed for debug version
* jsl DB~NEW
*
* -- Rest is for non-debug version
using memglobal
lock memmutex
jsl ~NEW
unlock memmutex
MEND
@ -1970,5 +1945,44 @@ skip&syscnt anop
MACRO
&lab ~DISPOSE
&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

View File

@ -1,7 +1,7 @@
/*
* 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"
@ -16,7 +16,7 @@
resource rVersion (1, purgeable3) {
{ 2, 0, 0, /* Version 2.0.0 */
development, /* development|alpha|beta|final|release */
7 }, /* non-final release number */
8 }, /* non-final release number */
verUS, /* Country */
PROG, /* Program name */
DESC

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
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
phd
tcd
lda num
bne hasher
lda num If this isn't the first time
bne hasher through, reuse the value of "h".
;
; First time through for the name: calculate value for "h"
;
stz h
ldy #0
loop lda [name],y
and #$FF
beq hasher
sta addit+1
sta addit+1 Modify "adc #$FFFF"
lda h ;left shift 7
xba
and #$FF00
lsr a
addit adc #0 ;(cf=0)
addit adc #$FFFF NOTE: immediate data was modified.
phy
UDivide (@a,t_size),(@a,@a)
sta h
@ -123,6 +132,9 @@ addit adc #0 ;(cf=0)
iny
bra loop
;
; "h" has been calculated; now do the rest of the hash function
;
hasher lda num ;num*num
sta tmp
lda #0
@ -139,7 +151,7 @@ nomul dex
asl a
asl a
sec
sbc 1,s
sbc 1,s (Use top word on stack as temp var)
asl a
asl a
adc 1,s
@ -154,9 +166,12 @@ nomul dex
adc h
sec
sbc num
plx
plx (Remove temp var from stack)
UDivide (@a,t_size),(@a,@y)
;
; Return the hashed value to the user
;
lda space
sta end-2
pld
@ -165,10 +180,10 @@ nomul dex
adc #end-3
tcs
tya
tya Final hash value is in accumulator.
rts
h ds 2
h ds 2 NOTE: h must be a "static" variable.
tmp ds 2
END
@ -359,6 +374,8 @@ done anop
**************************************************************************
search START
using hashdata
ptr equ 1
name_len equ ptr+4
@ -379,6 +396,8 @@ end equ file+4
phd
tcd
lock hashmutex
stz qh
stz full_path Set result to NULL.
stz full_path+2
@ -468,7 +487,9 @@ found lda [ptr]
pha
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
; Adjust stack in preparation for return
@ -572,6 +593,9 @@ ptr equ numEntries+2
space equ ptr+4
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
;
@ -731,6 +755,7 @@ hashpath START
using hashdata
using vardata
using global
len equ 1
pathnum equ len+2
@ -1062,7 +1087,7 @@ filesdone anop
ph4 gsosbuf Free memory allocated for
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.
Int2Dec (hash_numexe,#hashnum,#3,#0)
@ -1090,8 +1115,6 @@ noprint anop
rtl
hashmutex key Mutual exclusion key
pathname gsstr 'path'
hashmsg dc c'hashed '
@ -1167,12 +1190,13 @@ done rts
hashdata DATA
hashmutex key Mutual exclusion key
t_size ds 2 t_size = (TAB_MULT * numexe) - 1
hash_paths dc 32i4'0' 32 paths max for now.
hash_files dc i4'0'
hash_table dc i4'0' Pointer to table (t_size entries)
hash_numexe dc i2'0' Number of hashed executables
hash_print dc i2'0' Print flag; 0 until init is complete
END

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
* NOTE: only called from invoke, after fork_mutex is locked
tsc
phd
tcd
@ -672,7 +674,7 @@ prefork lock fork_mutex Lock the fork mutual exclusion.
;
; Tasks the parent process does right after forking
;
postfork sta rtnval
postfork sta rtnval Save pid as return value.
lda pipein If pipein != 0,
beq postfork2
sta CloseRef
@ -723,11 +725,18 @@ postfork6 rts
;
infork phk Make sure data bank register
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
Open ttyopen Open tty.
optty Open ttyopen Open tty.
jcs errinfork
lda _pipein
@ -735,7 +744,6 @@ infork phk Make sure data bank register
tcnewpgrp ttyref allocate new process group.
infork0a settpgrp ttyref Set current process to have proc group.
lda _bg If in background,
and #$FF
beq infork0b
tctpgrp (gshtty,gshpid) reset tty to the shell process group.

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
* | | | | | |
* ^ ^ ^ ^ ^ ^
**************************************************************************
*
* 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
@ -894,7 +928,7 @@ done lda space,s
**************************************************************************
*
* JOBS: builtin command
* syntax: exit
* syntax: jobs
*
* displays jobs
*
@ -914,18 +948,16 @@ space equ status+2
stz pidflag
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
sta pp
ldy #4+2
@ -933,40 +965,62 @@ grab ldy #4
sta pp+2
lda [pp]
and #$FF
if2 @a,ne,#'-',shit
if2 @a,ne,#'-',prusage
ldy #1
lda [pp],y
if2 @a,ne,#'l',shit
inc pidflag
if2 @a,eq,#'l',optset
;
; 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
ldx pjoblist+2
;
; Inner loop: find entry in job list that matches the count number.
;
loop2 sta pp
stx pp+2
ora pp+2
beq next
ldy #p_index
lda [pp],y
cmp count
beq gotit
ldy #p_next+2
lda [pp],y
ora pp+2 If at end of list,
beq next there was no entry with this count!
ldy #p_index If p_index field
lda [pp],y in this entry
cmp count matches count,
beq gotit go print the contents.
ldy #p_next+2 Otherwise,
lda [pp],y point to next entry in list.
tax
ldy #p_next
lda [pp],y
bra loop2
gotit pei (pp+2)
gotit pei (pp+2) Push address of entry,
pei (pp)
pei (pidflag)
pea 0
jsl pprint
pei (pidflag) "long" flag,
pea 0 (signum = 0)
jsl pprint and print the entry.
next inc count
next inc count Bump count.
lda count
cmp pmaxindex
beq loop
cmp pmaxindex If more to be printed,
beq loop scan list for next entry.
bcc loop
done return 2:status

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
* | | | | | |
* ^ ^ ^ ^ ^ ^
**************************************************************************
*
* Interfaces defined in this file:
*
* edit subroutine (4:argv,2:argc) builtin command
*
**************************************************************************
mcopy /obj/gno/bin/gsh/orca.mac

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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 HistoryData
using termdata
using hashdata
p equ 0 General pointer
cflag equ p+4 Flag: set when path converted
@ -186,7 +185,8 @@ nopathconv anop
pha argc = 0
pha argv = NULL
pha
pha jobflag = 0
lda #$8000
pha jobflag = $8000
jsl ShellExec
; Read and execute $HOME/glogin
@ -209,7 +209,7 @@ fastskip2 anop
didit anop
jsr dispose_hash Remove old table (if set in
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
@ -385,7 +385,8 @@ no_ovf phx
pha argc = 0
pha argv = NULL
pha
pha jobflag = 0
lda #$8000
pha jobflag = $8000
jsl ShellExec
; Dispose $HOME/gshrc string
@ -587,6 +588,7 @@ gshtty ds 2
gshpid ds 2
exit_requested dc i'0' ;!=0 if exit
signalled dc i'0'
done_init dc i2'0' 0 until init is complete
FastFlag dc i'0'
CmdFlag dc i'0'

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
lda 4,s
ora 6,s
bne ok
lda 2,s
sta 6,s
lda 1,s
lda 4,s Hold address
tay parameter in
lda 6,s X and Y registers.
tax
lda 2,s Move return
sta 6,s address on
lda 1,s the stack.
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
rtl and return to caller.
ok ~DISPOSE NOTE: macro locks/unlocks mem mutex
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
;=====================================================================

View File

@ -6,7 +6,7 @@
* Jawaid Bazyar
* 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
* | | | | | |
* ^ ^ ^ ^ ^ ^
**************************************************************************
*
* 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
@ -233,19 +250,26 @@ nextlen pla
; a divide..
;
ldx #0
txa
dex
lda maxlen
clc
colloop inx
adc maxlen
cmp #80
bcc colloop
cpx #6+1
bcc okcol
ldx #6 ;limit of 6 columns
cpx #6+1 Make sure there
bcc okcol are no more
ldx #6 than 6 columns.
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)
;
@ -261,6 +285,7 @@ foocol anop
;
; find the index for each column...
;
lock offtblmutex
lda #0
tax
clc
@ -269,11 +294,12 @@ mkidxloop sta offtbl,x
adc numrow
cmp [base]
bcc mkidxloop
;
; well....I think we can print now (yay!)
;
asl numcol Double numcol since it's compared
stx numcol Double numcol since it's compared
ldx #0 against X to end the loop.
;
; Ready to print...
;
printloop lda offtbl,x
cmp [base]
bcs nextprint0
@ -311,13 +337,16 @@ nextprint0 jsr newline
dec numrow
bne printloop
doneprint return
unlock offtblmutex
return
;
; Offset table: one entry for each column
;
offtbl ds 14
offtblmutex key
END
**************************************************************************
@ -345,6 +374,8 @@ space equ 0
END
**************************************************************************
_qsort PRIVATE
vleft equ 0