Changes for gsh version 2.0d7:

Fixed several memory leaks.

Prefix command without any parameter (to list the prefixes) would cause
memory corruption when prefix had been invoked previously with a parameter.

Sourcing a command file from within an exec file could cause gsh to
wait forever, depending upon the commands executed in the sourced file.

All built-in commands return appropriate status: 1 for error, 0 for no error.

Fixed several cases where incorrect value was set in $status.

Added usage strings for tset, hash, commands, and history.

Fixed memory corruption error when edit command had no parameters.

When system() is called with pointer = NULL or with a command string that
causes gsh to detect an error (e.g., incompatibility with | and <), return
status of -1. In other cases, return process's status rather than always 0.

System would crash when output from a non-forked command was piped to
another process; for example   clear | cat > /tmp/list
This commit is contained in:
tribby
1998-12-21 23:57:08 +00:00
parent 7ec020a057
commit e7f2691599
18 changed files with 653 additions and 323 deletions

View File

@@ -1,19 +1,10 @@
Last updated: Oct. 25, 1998 By: Dave Tribby Last updated: Dec. 18, 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
Completed items are reported in file UpdateLog. Completed items are reported in file UpdateLog.
Executing the following exec file often results in a hang:
# Create exec file
set tmpcmd=/tmp/testcmds
echo "echo Sourcing $tmpcmd" > $tmpcmd
echo "/bin/ps -l" >> $tmpcmd
chtyp -l exec $tmpcmd
# Source that file; usually doesn't return
source $tmpcmd
Allow redirection of built-in commands' I/O even if they aren't forked. Allow redirection of built-in commands' I/O even if they aren't forked.
Rather than have each built-in command always be either forked or Rather than have each built-in command always be either forked or
@@ -21,7 +12,7 @@ non-forked, check dynamically and only fork when it's really necessary
(background or piped). (background or piped).
Identify limits built into gsh and how they can be changed; for example, Identify limits built into gsh and how they can be changed; for example,
size of $PATH <= 256; max programs in hash table = 256. command line cannot expand to > 1024 characters.
When a background process finishes and there's text in the input buffer, 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
@@ -31,8 +22,6 @@ 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 but executing the script as a command) causes the shell to wait for that
background process to end - not exactly what we want. background process to end - not exactly what we want.
Usage for alias and hash
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.
@@ -48,7 +37,7 @@ In expandvars (expand.asm):
Add error checking if out buf gets too big (> 1024) Add error checking if out buf gets too big (> 1024)
Get rid of fixed buffers Get rid of fixed buffers
[ -- below this line...probably not -- ] [ -- below this line...probably never will be done -- ]
write new memory management. write new memory management.

View File

@@ -1,6 +1,76 @@
GSH 2.0 UPDATES GSH 2.0 UPDATES
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
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
than 0 when an error is detected.
Detect when non-forked builtin or directory name as command
is combined with piped I/O, and ensure that situation is
properly cleaned up. (Formerly, "clear | cat > /tmp/list"
would cause a nasty crash.)
Dec 18 98 [dmt] In execute() (cmd.asm), when child process isn't active
and has no entry in the pid list, assume that pchild() has
already set $status rather than forcing $status to 0.
Dec 17 98 [dmt] argv and argc parameters were reversed in PrintHistory().
This didn't make a difference until argc was checked for != 0.
Dec 16 98 [dmt] Added waitstatus address parameters to command() and
invoke() so completion status can be reported from unforked
builtin commands. Added code in execute() to set status
reported from unforked builtin commands.
Reviewed all built-in commands to ensure they report 0 for
no error and 1 for error.
Fixed memory corruption error when edit command had no
parameters (it called free1024 with random address).
Added usage strings for tset, hash, commands, and history.
Dec 13 98 [dmt] Resolved (or at least closed the window of opportunity
on) defects reported in Oct. 6 and 10 entries. When a process
terminated quickly [kill(pid,0) returned -1], that child's
termination could interfere with detecting the next child's
termination. Solution: Modify removejentry() (jobs.asm) to
return 1 if entry is in list (indicating we expected status
from it) and 0 if it isn't. Modify execute (cmd.asm) to get
status via wait() if and only if removejobentry() returns 1.
Previously, the following exec file often resulted in a hang:
# Create exec file
set tmpcmd=/tmp/testcmds
echo "echo Sourcing $tmpcmd" > $tmpcmd
echo "/bin/ps -l" >> $tmpcmd
chtyp -l exec $tmpcmd
# Source that file; usually doesn't return
source $tmpcmd
Dec 5 98 [dmt] If either glogin file rehashed (for login shells only),
that hash table's memory pointer was overwritten but not
deallocated in shell (shell.asm). Fixed by adding a call to
dispose_hash before calling hashpath.
Nov 29 98 [dmt] Fix memory leak: deallocate name returned by hash
search in invoke (invoke.asm) and which (builtin.asm).
Deallocate path string in invoke by passing it as a new
parameter to argfree, so that it is deallocated only after
the child process is done with it.
Nov 28 98 [dmt] When allocating memory for return string containing
full path in search (hash.asm), add lengths of path + name + 1
rather than path + 33.
Nov 18 98 [dmt] Fix memory leak: when null command was encountered,
the empty command line and argv array were not deallocated.
Nov 12 98 [dmt] prefix command without parameters should not try to
deallocate PRecPath, since it was not used. Causes corruption
when PRecPath contains a value; fixed by jumping to done
rather than finish. Also, jump into "allloop" earlier and
avoid 9 lines of duplicate code.
Nov 2 98 [dmt] Changes to this point checked-in to master archive.
Released as version 2.0d6
Oct 29 98 [dmt] Defect introduced into 2.0d5 fixed: when background job Oct 29 98 [dmt] Defect introduced into 2.0d5 fixed: when background job
completed, GetCmdLine thought there was an error on stdin. It completed, GetCmdLine thought there was an error on stdin. It
printed a bogus error message and then quit. printed a bogus error message and then quit.

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: alias.asm,v 1.6 1998/09/08 16:53:05 tribby Exp $ * $Id: alias.asm,v 1.7 1998/12/21 23:57:04 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -25,7 +25,7 @@
* Returns with status=0 in Accumulator * Returns with status=0 in Accumulator
* *
* unalias subroutine (4:argv,2:argc) * unalias subroutine (4:argv,2:argc)
* Returns with status=0 in Accumulator * return 2:status
* *
* initalias jsr/rts with no parameters * initalias jsr/rts with no parameters
* *
@@ -240,16 +240,12 @@ spacestr dc c' ',h'00'
unalias START unalias START
space equ 1 status equ 0
argc equ space+3 space equ status+2
argv equ argc+2
end equ argv+4
; subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
tsc stz status
phd
tcd
lda argc lda argc
dec a dec a
@@ -258,6 +254,7 @@ end equ argv+4
ldx #^Usage ldx #^Usage
lda #USage lda #USage
jsr errputs jsr errputs
inc status Return status = 1.
bra done bra done
loop add2 argv,#4,argv loop add2 argv,#4,argv
@@ -273,19 +270,7 @@ loop add2 argv,#4,argv
bra loop bra loop
done lda space done return 2:status
sta end-3
lda space+1
sta end-2
pld
tsc
clc
adc #end-4
tcs
lda #0
rtl
Usage dc c'Usage: unalias name ...',h'0d00' Usage dc c'Usage: unalias name ...',h'0d00'

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: bufpool.asm,v 1.5 1998/09/08 16:53:05 tribby Exp $ * $Id: bufpool.asm,v 1.6 1998/12/21 23:57:04 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -22,9 +22,10 @@
************************************************************************** **************************************************************************
* *
* Interfaces defined in this file: * Interfaces defined in this file:
* The alloc routines are a jsl without any stack params. * The alloc routine is a jsl without any stack params.
* Pointer to requested buffer is returned in X/A registers. * Pointer to requested buffer is returned in X/A registers.
* alloc1024 * alloc1024
* The free routine takes the address from the X/A registers
* free1024 * free1024
* *
* bufpool data: * bufpool data:
@@ -40,7 +41,7 @@ dummybufpool start ; ends up in .root
************************************************************************** **************************************************************************
* *
* get a buffer of size 1024 * Get a buffer of size 1024
* *
************************************************************************** **************************************************************************
@@ -50,16 +51,16 @@ alloc1024 START
lock pool1024mutex lock pool1024mutex
lda pool1024 lda pool1024 If pool pointer
ora pool1024+2 ora pool1024+2 isn't NULL,
beq allocbuf beq allocbuf
phd phd
ph4 pool1024 ph4 pool1024 Push pool pointer on stack.
tsc tsc
tcd tcd
lda [1] lda [1] Replace pool pointer with
sta pool1024 sta pool1024 the address it points to.
ldy #2 ldy #2
lda [1],y lda [1],y
sta pool1024+2 sta pool1024+2
@@ -67,8 +68,11 @@ alloc1024 START
pla pla
plx plx
pld pld
rtl rtl Return to caller.
;
; No memory in free pool; must allocate a new block.
;
allocbuf unlock pool1024mutex allocbuf unlock pool1024mutex
ph4 #1024 ph4 #1024
~NEW ~NEW
@@ -78,7 +82,7 @@ allocbuf unlock pool1024mutex
************************************************************************** **************************************************************************
* *
* free a buffer of size 1024 * Free a buffer of size 1024, putting it into the free pool
* *
************************************************************************** **************************************************************************
@@ -92,32 +96,33 @@ free1024 START
tsc tsc
tcd tcd
lock pool1024mutex lock pool1024mutex
lda pool1024 lda pool1024 Move current head of pool list
sta [1] sta [1] into the buffer being freed.
ldy #2 ldy #2
lda pool1024+2 lda pool1024+2
sta [1],y sta [1],y
lda 1 lda 1 Put address of buffer being freed
sta pool1024 sta pool1024 into the pool list head.
lda 3 lda 3
sta pool1024+2 sta pool1024+2
unlock pool1024mutex unlock pool1024mutex
pla pla
plx plx
pld pld
rtl rtl Return to caller.
END END
************************************************************************** **************************************************************************
* *
* buffer pool data * Buffer pool data
* *
************************************************************************** **************************************************************************
bufpool DATA bufpool DATA
pool1024 dc i4'0' pool1024 dc i4'0' Head of free pool list.
pool1024mutex key
pool1024mutex key Mutual exclusion when modifying list.
END END

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: builtin.asm,v 1.7 1998/10/26 17:04:49 tribby Exp $ * $Id: builtin.asm,v 1.8 1998/12/21 23:57:04 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -129,8 +129,9 @@ foundit ldy #4
pei (argv) pei (argv)
pei (argc) pei (argc)
ourproc jsl >$FFFFFF ;might want to mutex this!!!!!! ourproc jsl >$FFFFFF ;might want to mutex this!!!!!!
sta val sta val Save return status.
ph4 #0 (no path)
pei (argc) pei (argc)
pei (argv+2) pei (argv+2)
pei (argv) pei (argv)
@@ -403,6 +404,7 @@ getinfo GetFileInfo GRec
bcc ok bcc ok
ohshit sta ErrError ohshit sta ErrError
ErrorGS Err ErrorGS Err
inc status Return status = 1.
bra done bra done
ok if2 GRecFT,eq,#$F,ok2 ok if2 GRecFT,eq,#$F,ok2
@@ -412,6 +414,7 @@ ok if2 GRecFT,eq,#$F,ok2
ldx #^direrr ldx #^direrr
lda #direrr lda #direrr
jsr errputs jsr errputs
inc status Return status = 1.
bra done bra done
; ;
@@ -440,7 +443,7 @@ exit unlock cdmutex
adc #end-4 adc #end-4
tcs tcs
tay Put return status in Accumulator. tya Put return status in Accumulator.
rtl rtl
@@ -498,10 +501,12 @@ end equ argv+4
ldx #^Usage ldx #^Usage
lda #Usage lda #Usage
jsr errputs jsr errputs
ldy #1 Return status = 1.
bra exit bra exit
clearit jsr clearscrn clearit jsr clearscrn
jsr flush jsr flush
ldy #0 Return status = 0.
exit lda space exit lda space
sta end-3 sta end-3
@@ -513,7 +518,7 @@ exit lda space
adc #end-4 adc #end-4
tcs tcs
lda #0 tya
rtl rtl
@@ -537,7 +542,8 @@ echo START
val equ 1 val equ 1
nl equ val+2 flag: was -n option set? nl equ val+2 flag: was -n option set?
ptr equ nl+2 ptr equ nl+2
space equ ptr+4 status equ ptr+4
space equ status+2
argc equ space+3 argc equ space+3
argv equ argc+2 argv equ argc+2
end equ argv+4 end equ argv+4
@@ -553,6 +559,7 @@ end equ argv+4
phd phd
tcd tcd
stz status Clear return status.
stz nl Clear the -n flag. stz nl Clear the -n flag.
dec argc Decrement argument counter. dec argc Decrement argument counter.
jeq done Done if no more arguments. jeq done Done if no more arguments.
@@ -578,6 +585,7 @@ end equ argv+4
showusage ldx #^Usage Incorrect parameter usage: showusage ldx #^Usage Incorrect parameter usage:
lda #Usage display the usage string. lda #Usage display the usage string.
jsr errputs jsr errputs
inc status Return status = 1.
jmp exit jmp exit
gotn iny gotn iny
@@ -662,7 +670,7 @@ done lda nl If "-n" flag isn't set,
jsr newline add a newline. jsr newline add a newline.
exit jsr flush Print the buffer. exit jsr flush Print the buffer.
ldy status
* Clear parameters from stack and return from subroutine. * Clear parameters from stack and return from subroutine.
@@ -676,7 +684,7 @@ exit jsr flush Print the buffer.
adc #end-4 adc #end-4
tcs tcs
lda #0 tya
rtl rtl
@@ -716,6 +724,7 @@ end equ argv+4
ldx #^Usage print the usage string. ldx #^Usage print the usage string.
lda #Usage lda #Usage
jsr errputs jsr errputs
ldy #1 Return status = 1.
bra exit bra exit
wait lock pwdmutex wait lock pwdmutex
@@ -744,6 +753,7 @@ freebuf ph4 ptr Free the buffer.
jsl nullfree jsl nullfree
done unlock pwdmutex done unlock pwdmutex
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.
@@ -755,7 +765,7 @@ exit lda space Deallocate stack space
adc #end-4 adc #end-4
tcs tcs
lda #0 Return status always 0. tya Return status.
rtl rtl
@@ -779,8 +789,10 @@ which START
using hashdata using hashdata
ptr equ 1 ptr equ 1
file equ ptr+4 sptr equ ptr+4
space equ file+4 file equ sptr+4
status equ file+4
space equ status+2
argc equ space+3 argc equ space+3
argv equ argc+2 argv equ argc+2
end equ argv+4 end equ argv+4
@@ -793,13 +805,16 @@ end equ argv+4
tcs tcs
phd phd
tcd tcd
stz status Clear return status.
; ;
; display usage if no arguments given ; Display usage if no argument
; ;
if2 argc,ge,#2,loop if2 argc,ge,#2,loop
ldx #^whicherr ldx #^whicherr
lda #whicherr lda #whicherr
jsr errputs jsr errputs
inc status Return status = 1
jmp exit jmp exit
; ;
; loop through each argument ; loop through each argument
@@ -858,7 +873,12 @@ tryhash pei (file+2)
; ;
; It was hashed, so say so. ; It was hashed, so say so.
; ;
foundhash jsr puts foundhash sta sptr
stx sptr+2
jsr puts
pei (sptr+2) Free memory allocated
pei (sptr) by search to hold full path.
jsl nullfree
jmp nextarg jmp nextarg
; ;
; It must be in the current prefix, so check it out. ; It must be in the current prefix, so check it out.
@@ -928,7 +948,8 @@ donecwd unlock pwdmutex
nextarg jsr newline nextarg jsr newline
jmp loop jmp loop
exit lda space exit ldy status
lda space
sta end-3 sta end-3
lda space+1 lda space+1
sta end-2 sta end-2
@@ -938,7 +959,7 @@ exit lda space
adc #end-4 adc #end-4
tcs tcs
lda #0 tya
rtl rtl
@@ -962,7 +983,7 @@ GRecAuxType ds 4
* PREFIX: builtin command * PREFIX: builtin command
* syntax: prefix [num [prefix]] * syntax: prefix [num [prefix]]
* *
* sets prefix number num to prefix * sets prefix number num to prefix or print list of all prefixes
* *
************************************************************************** **************************************************************************
@@ -971,7 +992,8 @@ prefix START
dir equ 1 dir equ 1
numstr equ dir+4 numstr equ dir+4
pfxnum equ numstr+4 pfxnum equ numstr+4
space equ pfxnum+2 status equ pfxnum+2
space equ status+2
argc equ space+3 argc equ space+3
argv equ argc+2 argv equ argc+2
end equ argv+4 end equ argv+4
@@ -987,6 +1009,7 @@ end equ argv+4
lock mutex lock mutex
stz status Clear return status.
lda argc Get number of arguments. lda argc Get number of arguments.
dec a dec a
beq showall If no parameters, show all prefixes. beq showall If no parameters, show all prefixes.
@@ -998,7 +1021,9 @@ end equ argv+4
ldx #^usage ldx #^usage
lda #usage lda #usage
jsr errputs jsr errputs
jmp done jmp badstat
; -------------------------------------------------------------------
; ;
; No parameters provided: show all the prefixes ; No parameters provided: show all the prefixes
; ;
@@ -1016,16 +1041,7 @@ showall anop
ldx #^bootstr ldx #^bootstr
lda #bootstr lda #bootstr
jsr puts bra printid Jump into the loop
ldx dir+2
lda dir X/A = address of
clc text (four bytes
adc #4 beyond start).
bcc doputs
inx
doputs jsr puts Print the directory name
jsr newline and a newline.
bra nextall Jump into the all loop.
allloop lda pfxnum allloop lda pfxnum
pha pha
@@ -1042,7 +1058,7 @@ allloop lda pfxnum
Int2Dec (pfxnum,#pfxstr,#2,#0) Int2Dec (pfxnum,#pfxstr,#2,#0)
ldx #^pfxstr ldx #^pfxstr
lda #pfxstr lda #pfxstr
jsr puts printid jsr puts
ldx dir+2 ldx dir+2
lda dir X/A = address of lda dir X/A = address of
clc text (four bytes clc text (four bytes
@@ -1056,8 +1072,9 @@ nextall ph4 dir Free the GS/OS result buffer
jsl nullfree allocated for pathname. jsl nullfree allocated for pathname.
bumppfx inc pfxnum Bump the prefix number. bumppfx inc pfxnum Bump the prefix number.
if2 pfxnum,cc,#32,allloop if2 pfxnum,cc,#32,allloop
jmp finish jmp done
; -------------------------------------------------------------------
; ;
; One parameter provided: show a single prefix ; One parameter provided: show a single prefix
; ;
@@ -1103,6 +1120,7 @@ donewline jsr newline
jsl nullfree allocated for pathname. jsl nullfree allocated for pathname.
jmp done jmp done
; -------------------------------------------------------------------
; ;
; Two parameters provided: set a prefix ; Two parameters provided: set a prefix
; ;
@@ -1149,6 +1167,7 @@ ok if2 GRecFT,eq,#$F,ok2 If filetype != $F,
ldx #^direrr print error message ldx #^direrr print error message
lda #direrr 'Not a directory' lda #direrr 'Not a directory'
jsr errputs jsr errputs
badstat inc status Return status = 1.
bra done bra done
ok2 SetPrefix PRec Set the prefix. ok2 SetPrefix PRec Set the prefix.
@@ -1156,13 +1175,22 @@ ok2 SetPrefix PRec Set the prefix.
ldx #^errorstr print error message ldx #^errorstr print error message
lda #errorstr 'could not set prefix, lda #errorstr 'could not set prefix,
jsr errputs pathname may not exist.' jsr errputs pathname may not exist.'
inc status Return status = 1.
; -------------------------------------------------------------------
;
; All done: cleanup and return
;
finish ph4 PRecPath Free the name string buffer. finish ph4 PRecPath Free the name string buffer.
jsl nullfree jsl nullfree
;
; Exit through here if PRecPath wasn't used
;
done unlock mutex done unlock mutex
ldy status
lda space lda space
sta end-3 sta end-3
lda space+1 lda space+1
@@ -1173,7 +1201,7 @@ done unlock mutex
adc #end-4 adc #end-4
tcs tcs
lda #0 tya
rtl rtl
@@ -1228,14 +1256,12 @@ ErrError ds 2 Error number
rehash START rehash START
unhash ENTRY unhash ENTRY
space equ 1 status equ 0
argc equ space+3 space equ status+2
argv equ argc+2
end equ argv+4
tsc subroutine (4:argv,2:argc),space
phd
tcd stz status
lda argc lda argc
dec a dec a
@@ -1251,6 +1277,7 @@ end equ argv+4
jsr errputs jsr errputs
lda #13 lda #13
jsr errputchar jsr errputchar
inc status Return status = 1.
bra exit bra exit
doit jsr dispose_hash ;remove old table doit jsr dispose_hash ;remove old table
@@ -1266,19 +1293,7 @@ doit jsr dispose_hash ;remove old table
if2 @a,eq,#'u',exit ;if 'rehash' do the hashing. if2 @a,eq,#'u',exit ;if 'rehash' do the hashing.
jsl hashpath ;hash the path jsl hashpath ;hash the path
exit lda space exit return 2:status
sta end-3
lda space+1
sta end-2
pld
tsc
clc
adc #end-4
tcs
lda #0
rtl
Usage dc c'Usage: ',h'00' Usage dc c'Usage: ',h'00'
@@ -1322,16 +1337,20 @@ setdebug START
arg equ 0 arg equ 0
newdebug equ arg+4 newdebug equ arg+4
mode equ newdebug+2 mode equ newdebug+2
space equ mode+2 status equ mode+2
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc lda argc
dec a dec a
bne ok bne ok
showusage ldx #^usage showusage ldx #^usage
lda #usage lda #usage
jsr errputs jsr errputs
inc status Return status = 1.
jmp return jmp return
ok stz mode ok stz mode
@@ -1377,7 +1396,7 @@ turnnext sta newdebug
done setdebug newdebug done setdebug newdebug
mv2 newdebug,globaldebug mv2 newdebug,globaldebug
return return 2:#0 return return 2:status
findflag incad arg findflag incad arg
ldy #0 ldy #0
@@ -1472,16 +1491,20 @@ ps2 equ t+4
pr2 equ ps2+4 pr2 equ ps2+4
pr equ pr2+4 pr equ pr2+4
ps equ pr+4 ps equ pr+4
space equ ps+4 status equ ps+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc lda argc
dec a dec a
beq ok beq ok
showusage ldx #^usage showusage ldx #^usage
lda #usage lda #usage
jsr errputs jsr errputs
inc status Return status = 1.
jmp return jmp return
ok getuid ok getuid
@@ -1494,6 +1517,7 @@ ok getuid
ldx #^kvmerrstr ldx #^kvmerrstr
lda #kvmerrstr lda #kvmerrstr
jsr errputs jsr errputs
inc status Return status = 1.
jmp done jmp done
ok2 ldx #^header ok2 ldx #^header
@@ -1679,7 +1703,7 @@ skip jmp loop
done kvm_close ps done kvm_close ps
return return 2:#0 return return 2:status
usage dc c'Usage: ps',h'0d00' usage dc c'Usage: ps',h'0d00'
kvmerrstr dc c'ps: error in kvm_open()',h'0d00' kvmerrstr dc c'ps: error in kvm_open()',h'0d00'
@@ -1723,11 +1747,24 @@ hashbi START
sv equ 0 sv equ 0
q equ sv+4 q equ sv+4
p equ q+4 p equ q+4
space equ p+4 status equ p+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
ph2 t_size Get size of hash table. stz status
lda argc
dec a
beq dohash
ldx #^Usage
lda #Usage
jsr errputs
inc status Return status = 1.
bra exit
dohash ph2 t_size Get size of hash table.
jsl sv_alloc Allocate a string vector array. jsl sv_alloc Allocate a string vector array.
sta sv sta sv
stx sv+2 stx sv+2
@@ -1791,7 +1828,9 @@ doneadd anop
pei (sv) pei (sv)
jsl sv_dispose Dispose of the string vector memory. jsl sv_dispose Dispose of the string vector memory.
exit return 2:#0 exit return 2:status
usage dc c'Usage: hash',h'0d00'
END END
@@ -1859,11 +1898,24 @@ cmdbi START
using BuiltinData using BuiltinData
sv equ 0 sv equ 0
space equ sv+4 status equ sv+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
ph2 #50 stz status
lda argc
dec a
beq docmds
ldx #^Usage
lda #Usage
jsr errputs
inc status Return status = 1.
bra exit
docmds ph2 #50
jsl sv_alloc jsl sv_alloc
sta sv sta sv
@@ -1903,6 +1955,8 @@ doneadd anop
pei (sv) pei (sv)
jsl sv_dispose jsl sv_dispose
exit return 2:#0 exit return 2:status
usage dc c'Usage: commands',h'0d00'
END END

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: cmd.asm,v 1.7 1998/10/26 17:04:49 tribby Exp $ * $Id: cmd.asm,v 1.8 1998/12/21 23:57:05 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -27,11 +27,11 @@
* Returns value of token in Accumulator * Returns value of token in Accumulator
* *
* command subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2, * command subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2,
* 4:pipesem,4:stream) * 4:pipesem,4:stream,4:awaitstatus)
* Called by execute to act on a single command * Called by execute to act on a single command
* Returns next token in Accumulator * Returns next token in Accumulator
* *
* argfree subroutine (2:argc,4:argv) * argfree subroutine (4:path,2:argc,4:argv)
* *
* ShellExec subroutine (4:path,2:argc,4:argv,2:jobflag) * ShellExec subroutine (4:path,2:argc,4:argv,2:jobflag)
* Reads and executes commands from an exec file. * Reads and executes commands from an exec file.
@@ -348,7 +348,8 @@ temp equ append+2
argc equ temp+4 argc equ temp+4
token equ argc+2 token equ argc+2
space equ token+2 space equ token+2
stream equ space+3 awaitstatus equ space+3
stream equ awaitstatus+4
pipesem equ stream+4 pipesem equ stream+4
inpipe2 equ pipesem+4 inpipe2 equ pipesem+4
jobflag equ inpipe2+2 jobflag equ inpipe2+2
@@ -356,7 +357,7 @@ inpipe equ jobflag+2
waitpid equ inpipe+2 waitpid equ inpipe+2
end equ waitpid+4 end equ waitpid+4
; subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2,4:pipesem,4:stream),space ; subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2,4:pipesem,4:stream,4:awaitstatus),space
tsc tsc
sec sec
@@ -612,7 +613,15 @@ tok_eof anop
lda #spcmdstr specify a command before redirecting. lda #spcmdstr specify a command before redirecting.
jsr errputs jsr errputs
nulldone lda #0 Clear the waitpid nulldone anop
pei (cmdline+2) Free buffers
pei (cmdline) allocated for
jsl nullfree command line
pei (argv+2) and argv.
pei (argv)
jsl nullfree
lda #0 Clear the waitpid
sta [waitpid] and return as if sta [waitpid] and return as if
lda #T_NULL nothing were parsed. lda #T_NULL nothing were parsed.
jmp exit jmp exit
@@ -639,7 +648,7 @@ bar2 clc Calculate 32-bit address
adc #pipefds pipefds in X and A. adc #pipefds pipefds in X and A.
ldx #0 ldx #0
pipe @xa Allocate 2 file descriptor pipe pipe @xa Allocate 2 file descriptor pipe
; >> NOTE: what if pipes return errors? ; >> NOTE: what if pipe returns error?
; ;
; Call invoke param size:name ; Call invoke param size:name
@@ -668,16 +677,24 @@ run2 phx
pei (pipefds) 2: pipeout2 (allocated: write end) pei (pipefds) 2: pipeout2 (allocated: write end)
pei (pipesem+2) 4: pipesem (param passed in) pei (pipesem+2) 4: pipesem (param passed in)
pei (pipesem) pei (pipesem)
pei (awaitstatus+2) 4: awaitstatus (address) [New for v2.0]
pei (awaitstatus)
lda #-1 Set waitstatus = -1; it will be set to
sta [awaitstatus] 0 or 1 iff unforked builtin is called.
jsl invoke jsl invoke
sta pid sta pid
cmp #-1 cmp #-1 If invoke detected an error,
beq exit beq exit all done.
; If next token is "|", recursively call command. ; If next token is "|", recursively call command.
if2 token,ne,#T_BAR,run3 if2 token,ne,#T_BAR,run3
lda #-1 Pre-set for error flag.
ldx pid If no child was forked,
beq exit all done.
pei (waitpid+2) 4: waitpid pei (waitpid+2) 4: waitpid
pei (waitpid) pei (waitpid)
pei (pipefds) 2: inpipe pei (pipefds) 2: inpipe
@@ -687,6 +704,8 @@ run2 phx
pei (pipesem) pei (pipesem)
pei (stream+2) 4: stream pei (stream+2) 4: stream
pei (stream) pei (stream)
pei (awaitstatus+2) 4: awaitstatus
pei (awaitstatus)
jsl command jsl command
bra exit bra exit
@@ -694,9 +713,10 @@ run3 lda pid
sta [waitpid] sta [waitpid]
lda token lda token
; clean up ;
; Free allocated memory and return to caller
exit pha ;
exit pha Hold return status on stack.
lda dstfile lda dstfile
ora dstfile+2 ora dstfile+2
@@ -726,7 +746,7 @@ ex3 anop
lda word lda word
jsl free1024 jsl free1024
ply ply Get return value.
lda space lda space
sta end-3 sta end-3
@@ -741,14 +761,18 @@ ex3 anop
tya tya
rtl rtl
error ldx #^err00 ;
; Print error message, deallocate memory, and return with value -1
;
error ldx #^err00 (Add high word of error address)
jsr errputs jsr errputs
tok_error pei (cmdline+2) tok_error pei (cmdline+2)
pei (cmdline) pei (cmdline)
jsl nullfree jsl nullfree
exit1a pei (argc) ph4 #0 (no path to be freed)
pei (argc)
pei (argv+2) pei (argv+2)
pei (argv) pei (argv)
jsl argfree jsl argfree
@@ -779,9 +803,13 @@ argfree START
space equ 0 space equ 0
subroutine (2:argc,4:argv),space subroutine (4:path,2:argc,4:argv),space
free1 lda argc pei path+2 Free the path.
pei path
jsl nullfree
free1 lda argc Free each of the argv elements.
beq free2 beq free2
dec a dec a
asl2 a asl2 a
@@ -795,7 +823,8 @@ free1 lda argc
jsl nullfree jsl nullfree
dec argc dec argc
bra free1 bra free1
free2 pei (argv+2)
free2 pei (argv+2) Free the argv array.
pei (argv) pei (argv)
jsl nullfree jsl nullfree
return return
@@ -1135,10 +1164,10 @@ execute START
exebuf equ 1 exebuf equ 1
pipesem equ exebuf+4 pipesem equ exebuf+4
ptr2 equ pipesem+2 ptr_glob equ pipesem+2
waitstatus equ ptr2+4 waitstatus equ ptr_glob+4
ptr equ waitstatus+2 ptr_envexp equ waitstatus+2
pid equ ptr+4 pid equ ptr_envexp+4
term equ pid+2 term equ pid+2
cmdstrt equ term+2 cmdstrt equ term+2
cmdend equ cmdstrt+4 cmdend equ cmdstrt+4
@@ -1284,48 +1313,48 @@ expand anop
pei (cmdstrt+2) pei (cmdstrt+2)
pei (cmdstrt) pei (cmdstrt)
jsl expandvars jsl expandvars
sta ptr_envexp
stx ptr_envexp+2
; Expand wildcard characters in the modified command line ; Expand wildcard characters in the modified command line
phx phx
pha pha
sta ptr
stx ptr+2
jsl glob jsl glob
sta ptr_glob
stx ptr_glob+2
; Expand aliases in the modified command line ; Expand aliases in the modified command line (final expansion)
phx phx
pha pha
sta ptr2
stx ptr2+2
jsl expandalias jsl expandalias
phx
pha
sta exebuf sta exebuf
stx exebuf+2 stx exebuf+2
phx Put exebuf on stack for
pha nullfree at endcmd.
* >> Temporary debug code: echo expanded command if echo is set. * >> Temporary debug code: echo expanded command if echo is set.
using vardata using vardata
lda varecho ldy varecho
beq noecho beq noecho
ldx exebuf+2 jsr puts NOTE: x/a = exebuf
lda exebuf
jsr puts
jsr newline jsr newline
noecho anop noecho anop
ldx ptr_envexp+2 Free memory allocated
ldx ptr+2 lda ptr_envexp for env var expansion
lda ptr
jsl free1024 jsl free1024
ldx ptr2+2 ldx ptr_glob+2 and globbing.
lda ptr2 lda ptr_glob
jsl free1024 jsl free1024
;
; If exebuf pointer is null, bail out.
; >> NOTE: if exebuf is checked for null, shouldn't the other ptrs?
;
lda exebuf lda exebuf
ora exebuf+2 ora exebuf+2
bne loop bne loop
pla pla
pla pla
stz term stz term
@@ -1334,7 +1363,7 @@ noecho anop
* command subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2, * command subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2,
* 4:pipesem,4:stream) * 4:pipesem,4:stream,4:awaitstatus)
loop pea 0 ;Bank 0 waitpid (hi) loop pea 0 ;Bank 0 waitpid (hi)
tdc tdc
clc clc
@@ -1353,23 +1382,39 @@ loop pea 0 ;Bank 0 waitpid (hi)
clc clc
adc #exebuf adc #exebuf
pha stream (low) pha stream (low)
pea 0 ;Bank 0 status (hi) [New: v2.0]
tdc
clc
adc #waitstatus
pha status (low)
jsl command jsl command
sta term sta term Save result in term.
jmi noerrexit jmi errexit If < 0, all done.
lda pid ; If waitstatus != -1, executed command was a non-forked builtin,
jeq donewait ; and waitstatus is its completion status.
lda waitstatus
cmp #-1 cmp #-1
jeq noerrexit beq chkpid
jsr setstatus Set $status.
bra godonewait No need to wait.
lda jobflag chkpid lda pid Get child process id.
jeq jobwait beq godonewait If 0 (no fork), no need to wait.
cmp #-1 If -1 (error), all done.
jeq errexit
signal (#SIGINT,#0) lda jobflag If jobflag is set,
phx beq jobwait do more complicated wait.
pha
signal (#SIGTSTP,#0) ;
; Uncomplicated wait: simply call wait() to get child's termination status
;
signal (#SIGINT,#0) Use default interrupt and
phx keyboard stop signal handlers,
pha and put address of current
signal (#SIGTSTP,#0) handlers on the stack.
phx phx
pha pha
@@ -1384,53 +1429,79 @@ otherwait anop
lda waitstatus lda waitstatus
and #$FF and #$FF
cmp #$7F Check for WSTOPPED status. cmp #$7F Check for WSTOPPED status.
beq otherwait beq otherwait Something else...wait again.
lda waitstatus
jsr setstatus
pla lda waitstatus
plx jsr setstatus Set process's $status.
pla Restore gsh's interrupt and
plx keyboard stop signal handlers.
signal (#SIGTSTP,@xa) signal (#SIGTSTP,@xa)
pla pla
plx plx
signal (#SIGINT,@xa) signal (#SIGINT,@xa)
bra donewait godonewait bra donewait
;
; jobflag = 0: need more complicated wait for child
;
jobwait anop jobwait anop
signal (#SIGCHLD,#pchild) Ensure child sig handler active. signal (#SIGCHLD,#pchild) Ensure child sig handler active.
phx Save address of previous sig handler. phx Save address of previous sig handler.
pha pha
kill (pid,#0) If child no longer exists, kill (pid,#0) If child no longer exists
beq wait4job beq wait4job
pei pid pei pid
jsl removejentry Remove it from the list. jsl removejentry Remove its pid from the list.
bra setwstat beq restoresigh Pid not in list: assume $status set.
wait4job jsl pwait Otherwise, wait for it.
setwstat stz waitstatus ldx #0
pla Restore previous child completion clc
tdc
adc #waitstatus
wait @xa Get child completion status.
lda waitstatus
jsr setstatus Set process's $status.
bra restoresigh
;
; Child is active: wait for it to complete and get its status.
; NOTE: $status is set by SIGCHLD signal handler, pchild
;
wait4job jsl pwait Wait for child using pchild
restoresigh pla Restore previous child completion
plx signal handler. plx signal handler.
signal (#SIGCHLD,@xa) signal (#SIGCHLD,@xa)
; If command detected EOF terminator, all done ;
donewait if2 term,eq,#T_EOF,noerrexit ; Done waiting for completion status. Check the token last parsed
lda [exebuf] If not at end of line, ; from the command line.
;
donewait if2 term,eq,#T_EOF,endcmd If last token was EOF
lda [exebuf] or if next character is \0,
and #$FF and #$FF
beq exit beq endcmd all done with this command.
jmp loop process the next command.
jmp loop Process the next command.
; ;
; NOTE: non-forked builtins have no mechanism to return command status ; Underlying routine detected an error. Set waitstatus = -1
; ;
errexit lda #-1
sta waitstatus
noerrexit stz waitstatus ;
; We have completed processing of a command
exit jsl nullfree ;
lda term ;make sure we return -1 if error endcmd jsl nullfree Free exebuf (addr on stack).
lda term Return -1 if error
bmi chk_cmd bmi chk_cmd
lda waitstatus lda waitstatus Get completion status, and convert
xba xba from wait() format to byte value.
and #$FF and #$FF
; ;
@@ -1488,14 +1559,15 @@ space equ retval+2
lda str If user passes a lda str If user passes a
ora str+2 null pointer, ora str+2 null pointer,
bne makecall bne makecall
ina return 1 to caller. dec a return -1 to caller.
bra setrtn
; ;
; Let execute(str,1) do the work ; Let execute(str,1) do the work
; ;
makecall pei (str+2) makecall pei (str+2)
pei (str) pei (str)
ph2 #1 jobflag=1 says we're called by system ph2 #1 jobflag=1
jsl execute jsl execute
; ;
; Set status and go back to the caller ; Set status and go back to the caller

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: dir.asm,v 1.7 1998/10/26 17:04:50 tribby Exp $ * $Id: dir.asm,v 1.8 1998/12/21 23:57:05 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -79,10 +79,12 @@ dirs START
using DirData using DirData
arg equ 0 arg equ 0
space equ arg+4 status equ arg+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc lda argc
dec a dec a
beq showshort beq showshort
@@ -107,6 +109,7 @@ space equ arg+4
using ldx #^usingstr using ldx #^usingstr
lda #usingstr lda #usingstr
jsr errputs jsr errputs
inc status Return status = 1.
bra exit bra exit
showlong jsl dotods Set top of stack to current directory. showlong jsl dotods Set top of stack to current directory.
@@ -118,7 +121,7 @@ showshort jsl dotods Set top of stack to current directory.
pea 1 pea 1
jsl showdir jsl showdir
exit return 2:#0 exit return 2:status
usingstr dc c'usage: dirs [-l]',h'0d00' usingstr dc c'usage: dirs [-l]',h'0d00'
@@ -141,10 +144,12 @@ pushd START
count equ 0 count equ 0
p equ count+2 p equ count+2
arg equ p+4 arg equ p+4
space equ arg+4 status equ arg+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc Get number of arguments. lda argc Get number of arguments.
dec a If no parameters, dec a If no parameters,
beq xchange exchange top two dirs on stack. beq xchange exchange top two dirs on stack.
@@ -283,6 +288,7 @@ godir anop
ldx #^errfull print error message. ldx #^errfull print error message.
lda #errfull lda #errfull
prerrmsg jsr errputs prerrmsg jsr errputs
inc status Return status = 1.
bra exit bra exit
stackok anop stackok anop
jsl dotods Set top of stack to current directory. jsl dotods Set top of stack to current directory.
@@ -306,7 +312,7 @@ 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:#0 exit 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'
@@ -333,10 +339,12 @@ popd START
count equ 0 count equ 0
arg equ count+2 arg equ count+2
space equ arg+4 status equ arg+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc lda argc
dec a dec a
jeq noarg jeq noarg
@@ -356,6 +364,7 @@ space equ arg+4
using ldx #^usingstr using ldx #^usingstr
lda #usingstr lda #usingstr
jsr errputs jsr errputs
inc status Return status = 1.
jmp exit jmp exit
plus add4 arg,#1,arg plus add4 arg,#1,arg
@@ -377,6 +386,7 @@ plus add4 arg,#1,arg
pluserr ldx #^err2 pluserr ldx #^err2
lda #err2 lda #err2
jsr errputs jsr errputs
inc status Return status = 1.
bra exit bra exit
doplus jsl dotods Set top of stack to current directory. doplus jsl dotods Set top of stack to current directory.
@@ -408,6 +418,7 @@ noarg lda tods
ldx #^err1 ldx #^err1
lda #err1 lda #err1
jsr errputs jsr errputs
inc status Return status = 1.
bra exit bra exit
noarg0 lda tods noarg0 lda tods
@@ -437,7 +448,7 @@ gototop lda tods
pea 1 pea 1
jsl showdir jsl showdir
exit return 2:#0 exit 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'

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: edit.asm,v 1.8 1998/11/02 17:40:56 tribby Exp $ * $Id: edit.asm,v 1.9 1998/12/21 23:57:06 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -1733,17 +1733,21 @@ bindkey START
str equ 0 str equ 0
func equ str+4 func equ str+4
arg equ func+2 arg equ func+2
space equ arg+4 status equ arg+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc lda argc
dec a dec a
bne ok bne ok
showusage ldx #^usage showusage ldx #^usage
lda #usage lda #usage
jsr errputs jsr errputs
jmp exit inc status
bra goexit
ok dec argc ok dec argc
add2 argv,#4,argv add2 argv,#4,argv
@@ -1765,7 +1769,7 @@ ok dec argc
list ldx #^liststr list ldx #^liststr
lda #liststr lda #liststr
jsr puts jsr puts
jmp exit bra goexit
startbind lda argc startbind lda argc
dec a dec a
@@ -1797,8 +1801,8 @@ nofind pla
ldx #^errstr ldx #^errstr
lda #errstr lda #errstr
jsr errputs jsr errputs
lda #-1 inc status
jmp exit goexit bra exit
foundit pla foundit pla
lsr a lsr a
@@ -1838,7 +1842,7 @@ foundit pla
pei (str) pei (str)
jsl nullfree jsl nullfree
exit return exit return 2:status
usage dc c'Usage: bindkey [-l] function string',h'0d00' usage dc c'Usage: bindkey [-l] function string',h'0d00'
errstr dc c': undefined function',h'0d00' errstr dc c': undefined function',h'0d00'

View File

@@ -1,7 +1,7 @@
/* /*
* Resources for version and comment * Resources for version and comment
* *
* $Id: gsh.rez,v 1.7 1998/11/02 17:40:56 tribby Exp $ * $Id: gsh.rez,v 1.8 1998/12/21 23:57:06 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 */
6 }, /* non-final release number */ 7 }, /* 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.6 1998/09/08 16:53:09 tribby Exp $ * $Id: hash.asm,v 1.7 1998/12/21 23:57:06 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -361,7 +361,8 @@ done anop
search START search START
ptr equ 1 ptr equ 1
full_path equ ptr+4 name_len equ ptr+4
full_path equ name_len+2
qh equ full_path+4 qh equ full_path+4
space equ qh+2 space equ qh+2
paths equ space+3 paths equ space+3
@@ -428,6 +429,12 @@ found lda [ptr]
sta ptr sta ptr
ldx paths+2 ldx paths+2
stx ptr+2 stx ptr+2
pei (file+2)
pei (file)
jsr cstrlen Get length of prog name.
sta name_len
ldy #2 ldy #2
lda [ptr],y lda [ptr],y
pha pha
@@ -435,8 +442,8 @@ found lda [ptr]
pha pha
jsr cstrlen Get length of path. jsr cstrlen Get length of path.
pha pha
clc sec
adc #33 Add 33 (max prog name size + 1) adc name_len Add name length + 1 (carry bit).
pea 0 pea 0
pha pha
~NEW Allocate memory, ~NEW Allocate memory,

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: history.asm,v 1.6 1998/09/08 16:53:10 tribby Exp $ * $Id: history.asm,v 1.7 1998/12/21 23:57:06 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -584,11 +584,24 @@ PrintHistory START
using global using global
ptr equ 0 ptr equ 0
space equ ptr+4 status equ ptr+4
space equ status+2
subroutine (2:argc,4:argv),space subroutine (4:argv,2:argc),space
lda historyptr stz status
lda argc
dec a
beq chkptr
ldx #^usage
lda #usage
jsr errputs
inc status Return status = 1.
bra done
chkptr lda historyptr
ora historyptr+2 ora historyptr+2
beq done beq done
@@ -626,12 +639,14 @@ ok jsr puts
next dec num next dec num
bra loop1 bra loop1
done return 2:#0 done return 2:status
numbstr dc c'0000: ',h'00' numbstr dc c'0000: ',h'00'
num ds 2 num ds 2
count ds 2 count ds 2
usage dc c'Usage: history',h'0d00'
END END
;========================================================================= ;=========================================================================

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: invoke.asm,v 1.8 1998/10/26 17:04:50 tribby Exp $ * $Id: invoke.asm,v 1.9 1998/12/21 23:57:06 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -29,7 +29,7 @@
* *
* invoke subroutine (2:argc,4:argv,4:sfile,4:dfile,4:efile,2:app, * invoke subroutine (2:argc,4:argv,4:sfile,4:dfile,4:efile,2:app,
* 2:eapp,2:bg,4:cline,2:jobflag,2:pipein,2:pipeout, * 2:eapp,2:bg,4:cline,2:jobflag,2:pipein,2:pipeout,
* 2:pipein2,2:pipeout2,4:pipesem) * 2:pipein2,2:pipeout2,4:pipesem,4:awaitstatus)
* return 2:rtnval * return 2:rtnval
* *
************************************************************************** **************************************************************************
@@ -226,12 +226,15 @@ biflag equ p+4
ptr equ biflag+2 ptr equ biflag+2
rtnval equ ptr+4 Return pid, -1 (error), or 0 (no fork) rtnval equ ptr+4 Return pid, -1 (error), or 0 (no fork)
cpath equ rtnval+2 cpath equ rtnval+2
space equ cpath+4 hpath equ cpath+4
space equ hpath+4
subroutine (2:argc,4:argv,4:sfile,4:dfile,4:efile,2:app,2:eapp,2:bg,4:cline,2:jobflag,2:pipein,2:pipeout,2:pipein2,2:pipeout2,4:pipesem),space subroutine (2:argc,4:argv,4:sfile,4:dfile,4:efile,2:app,2:eapp,2:bg,4:cline,2:jobflag,2:pipein,2:pipeout,2:pipein2,2:pipeout2,4:pipesem,4:awaitstatus),space
ld2 -1,rtnval ld2 -1,rtnval
stz biflag Clear built-in flag. stz biflag Clear built-in flag
stz hpath and address from hash table.
stz hpath+2
lda argc If number of arguments == 0, lda argc If number of arguments == 0,
bne chknull nothing to do. (Shouldn't happen bne chknull nothing to do. (Shouldn't happen
@@ -275,6 +278,8 @@ chknull ldy #2 Move 1st argument
changeit sta cpath Use full path from changeit sta cpath Use full path from
stx cpath+2 hash table. stx cpath+2 hash table.
sta hpath Save adddress for deallocation.
stx hpath+2
; ;
; Get information about the command's filename ; Get information about the command's filename
@@ -437,8 +442,14 @@ doDir lock cdmutex
mv4 GRecPath,PRecPath mv4 GRecPath,PRecPath
SetPrefix PRec SetPrefix PRec
unlock cdmutex unlock cdmutex
stz rtnval Return value: no fork done. pei (ptr+2) Free memory used to hold
jmp free pei (ptr) GS/OS string with path.
jsl nullfree
lda #0 Completion status = 0.
;
; Rest of cleanup is shared with non-forked builtin
;
jmp nfcleanup
* *
* --------------------------------------------------------------- * ---------------------------------------------------------------
@@ -470,7 +481,8 @@ doShell anop
; Forked shell starts here... ; Forked shell starts here...
; ;
exec0 anop exec0 anop
ph2 _argc ;for argfree ph4 _hpath argfree parameters.
ph2 _argc
ph4 _argv ph4 _argv
ph4 _cpath ShellExec parameters ph4 _cpath ShellExec parameters
@@ -549,8 +561,18 @@ noforkbuiltin anop
pei (argv+2) pei (argv+2)
pei (argv) pei (argv)
jsl builtin jsl builtin
stz rtnval Return value: no fork done. and #$00FF Make return status look like result of
bra done xba wait(): high-order byte = status.
nfcleanup anop
sta [awaitstatus]
stz rtnval Return value (pid) = no fork done.
;
; There might be a process waiting on a pipe
;
lda [pipesem]
sta _semaphore
bra chkpipe
* *
* --------------------------------------------------------------- * ---------------------------------------------------------------
@@ -569,8 +591,8 @@ notfound pei (ptr+2)
lda #err2 'Command not found.' lda #err2 'Command not found.'
jsr errputs jsr errputs
lda pipein chkpipe lda pipein
beq notfound0 beq done
; Input being piped into a command that was not found. ; Input being piped into a command that was not found.
@@ -585,14 +607,15 @@ notfound pei (ptr+2)
inc a inc a
kill (@a,#9) Kill all processes in that group. kill (@a,#9) Kill all processes in that group.
sigpause #0 sigpause #0
notfound0 anop
done cop $7F done cop $7F
lda biflag If built-in flag is clear, lda biflag If built-in flag is clear,
bne skipfrarg bne skipfrarg
pei (argc) free arguments. pei (hpath+2) Free arguments.
pei (hpath)
pei (argc)
pei (argv+2) pei (argv+2)
pei (argv) pei (argv)
jsl argfree jsl argfree
@@ -625,6 +648,7 @@ prefork lock fork_mutex Lock the fork mutual exclusion.
mv2 eapp,_eapp mv2 eapp,_eapp
mv4 cline,_cline mv4 cline,_cline
mv4 cpath,_cpath mv4 cpath,_cpath
mv4 hpath,_hpath
mv2 argc,_argc mv2 argc,_argc
mv4 argv,_argv mv4 argv,_argv
mv2 pipein,_pipein mv2 pipein,_pipein
@@ -703,7 +727,7 @@ infork phk Make sure data bank register
lda _jobflag If jobflag == 0, lda _jobflag If jobflag == 0,
bne infork0b bne infork0b
Open ttyopen Open ttyopen Open tty.
jcs errinfork jcs errinfork
lda _pipein lda _pipein
@@ -786,6 +810,7 @@ _app dc i2'0'
_eapp dc i2'0' _eapp dc i2'0'
_cline dc i4'0' _cline dc i4'0'
_cpath dc i4'0' _cpath dc i4'0'
_hpath dc i4'0'
_pipein dc i2'0' _pipein dc i2'0'
_pipeout dc i2'0' _pipeout dc i2'0'
_pipein2 dc i2'0' _pipein2 dc i2'0'
@@ -803,7 +828,7 @@ err2 dc c': Command not found.',h'0d00'
deadstr dc c'Cannot fork (too many processes?)',h'0d00' ;try a spoon deadstr dc c'Cannot fork (too many processes?)',h'0d00' ;try a spoon
; Parameter block for GS/OC call GetFileInfo ; Parameter block for GS/OS call GetFileInfo
GRec dc i'4' pCount (# of parameters) GRec dc i'4' pCount (# of parameters)
GRecPath ds 4 pathname (input; ptr to GS/OS string) GRecPath ds 4 pathname (input; ptr to GS/OS string)
ds 2 access (access attributes) ds 2 access (access attributes)

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: jobs.asm,v 1.7 1998/10/26 17:04:50 tribby Exp $ * $Id: jobs.asm,v 1.8 1998/12/21 23:57:06 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -81,8 +81,8 @@ pwait START
using pdata using pdata
waitpid equ 1 mypid equ 1
oldsig equ waitpid+2 oldsig equ mypid+2
p equ oldsig+4 p equ oldsig+4
space equ p+4 space equ p+4
end equ space+3 end equ space+3
@@ -97,7 +97,7 @@ end equ space+3
tcd tcd
getpid Get process ID. getpid Get process ID.
sta waitpid sta mypid
; ;
; Start of loop that waits for child processes to complete ; Start of loop that waits for child processes to complete
@@ -125,15 +125,15 @@ loop sta p Save job entry pointer in p.
ldy #p_flags Get entry's job status flags. ldy #p_flags Get entry's job status flags.
lda [p],y lda [p],y
and #PFOREGND+PRUNNING and #PFOREGND+PRUNNING
cmp #PFOREGND+PRUNNING cmp #PFOREGND+PRUNNING If running in foreground,
bne getnext bne getnext look at the next entry.
ldy #p_pid Get entry's process ID. ldy #p_pid Get entry's process ID.
lda [p],y lda [p],y
cmp waitpid cmp mypid If it's this processes' pid,
beq getnext beq getnext look at the next entry.
; check if the process is actually running..if it is not, report to the ; Check if the process is actually running..if it is not, report to the
; user that a stale process was detected and remove it from job control. ; user that a stale process was detected and remove it from job control.
unlock plistmutex unlock plistmutex
@@ -510,14 +510,14 @@ end equ code+2
wait @xa wait @xa
sta pid sta pid
; ;
; search for the job that has finished. ; Search job list for the process that has finished.
; ;
lda pjoblist lda pjoblist
ldx pjoblist+2 ldx pjoblist+2
lookloop sta p lookloop sta p
stx p+2 stx p+2
ora p+2 ora p+2 If at end of job list,
jeq done jeq done the process was not found.
ldy #p_jobid ldy #p_jobid
lda [p],y lda [p],y
cmp pid cmp pid
@@ -528,8 +528,9 @@ lookloop sta p
ldy #p_next ldy #p_next
lda [p],y lda [p],y
bra lookloop bra lookloop
; ;
; see how wait was signaled. ; See how wait was signaled.
; ;
lookfound anop lookfound anop
lda waitstatus lda waitstatus
@@ -660,7 +661,8 @@ valstat_text dc c'000' Text (up to three digits)
;==================================================================== ;====================================================================
; ;
; remove an entry in the job list, based on process number ; Remove an entry in the job list, based on process number
; Return with A-reg = 1 if found, 0 if not found
; ;
;==================================================================== ;====================================================================
@@ -670,7 +672,8 @@ removejentry START
p equ 1 p equ 1
prev equ p+4 prev equ p+4
space equ prev+4 found equ prev+4
space equ found+2
pid equ space+3 process id pid equ space+3 process id
end equ pid+2 end equ pid+2
@@ -683,6 +686,7 @@ end equ pid+2
phd phd
tcd tcd
stz found
stz prev stz prev
stz prev+2 stz prev+2
lock plistmutex Ensure list doesn't change. lock plistmutex Ensure list doesn't change.
@@ -710,7 +714,8 @@ loop sta p Get next entry in job list.
; ;
; Entry found: adjust linked list pointers ; Entry found: adjust linked list pointers
; ;
gotit ora2 prev,prev+2,@a If prev != NULL, gotit inc found found = TRUE
ora2 prev,prev+2,@a If prev != NULL,
beq gotit2 beq gotit2
ldy #p_next prev->next = p->next ldy #p_next prev->next = p->next
lda [p],y lda [p],y
@@ -830,6 +835,7 @@ gotmax mv2 prev,pmaxindex
done anop done anop
unlock plistmutex unlock plistmutex
ldy found
lda space+1 lda space+1
sta end-2 sta end-2
lda space lda space
@@ -839,6 +845,7 @@ done anop
clc clc
adc #end-4 adc #end-4
tcs tcs
tya Return value = found flag.
rtl rtl
@@ -900,11 +907,13 @@ jobs START
pidflag equ 0 pidflag equ 0
pp equ pidflag+2 pp equ pidflag+2
count equ pp+4 count equ pp+4
space equ count+2 status equ count+2
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz pidflag stz pidflag
stz status
lda argc lda argc
dec a dec a
beq cont beq cont
@@ -913,6 +922,7 @@ space equ count+2
shit ldx #^Usage shit ldx #^Usage
lda #Usage lda #Usage
jsr errputs jsr errputs
inc status Return status = 1.
jmp done jmp done
grab ldy #4 grab ldy #4
@@ -959,7 +969,7 @@ next inc count
beq loop beq loop
bcc loop bcc loop
done return 2:#0 done return 2:status
Usage dc c'Usage: jobs [-l]',h'0d00' Usage dc c'Usage: jobs [-l]',h'0d00'
@@ -980,7 +990,8 @@ ptr equ 1
arg equ ptr+4 arg equ ptr+4
signum equ arg+4 signum equ arg+4
pid equ signum+2 pid equ signum+2
space equ pid+2 status equ pid+2
space equ status+2
argc equ space+3 argc equ space+3
argv equ argc+2 argv equ argc+2
end equ argv+4 end equ argv+4
@@ -994,6 +1005,8 @@ end equ argv+4
phd phd
tcd tcd
stz status
lda argc lda argc
dec a dec a
bne init bne init
@@ -1001,6 +1014,7 @@ end equ argv+4
ldx #^Usage ldx #^Usage
lda #Usage lda #Usage
jsr errputs jsr errputs
inc status Return status = 1.
jmp done jmp done
init stz pid init stz pid
@@ -1047,6 +1061,7 @@ init stz pid
ohshitnum ldx #^err1 ohshitnum ldx #^err1
lda #err1 lda #err1
jsr errputs jsr errputs
inc status Return status = 1.
jmp done jmp done
getname lda [arg] getname lda [arg]
@@ -1074,6 +1089,7 @@ nameloop pei (arg+2)
ldx #^err3 ldx #^err3
lda #err3 lda #err3
jsr errputs jsr errputs
inc status Return status = 1.
bra done bra done
next dec argc next dec argc
@@ -1097,6 +1113,7 @@ getpid pei (arg+2)
ldx #^err2 ldx #^err2
lda #err2 lda #err2
jsr errputs jsr errputs
inc status Return status = 1.
bra done bra done
lister ldx #^liststr lister ldx #^liststr
@@ -1107,6 +1124,7 @@ lister ldx #^liststr
killnull ldx #^err4 killnull ldx #^err4
lda #err4 lda #err4
jsr errputs jsr errputs
inc status Return status = 1.
bra done bra done
dokill kill (pid,signum) dokill kill (pid,signum)
@@ -1115,8 +1133,10 @@ dokill kill (pid,signum)
ldx #^err2 ldx #^err2
lda #err2 lda #err2
jsr errputs jsr errputs
inc status Return status = 1.
done lda space done ldy status
lda space
sta end-3 sta end-3
lda space+1 lda space+1
sta end-2 sta end-2
@@ -1126,7 +1146,7 @@ done lda space
adc #end-4 adc #end-4
tcs tcs
lda #0 tya
rtl rtl
@@ -1188,10 +1208,12 @@ fg START
pid equ 0 pid equ 0
p equ pid+2 p equ pid+2
space equ p+4 status equ p+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc lda argc
dec a dec a
bne getit bne getit
@@ -1278,8 +1300,9 @@ whoashit ldx #^err01
nojob ldx #^err03 nojob ldx #^err03
lda #err03 lda #err03
puterr jsr errputs puterr jsr errputs
inc status Return status = 1.
done return 2:#0 done return 2:status
usage dc c'Usage: fg [%job | pid]',h'0d00' usage dc c'Usage: fg [%job | pid]',h'0d00'
err01 dc c'fg: No job to foreground.',h'0d00' err01 dc c'fg: No job to foreground.',h'0d00'
@@ -1301,10 +1324,12 @@ bg START
pid equ 0 pid equ 0
p equ pid+2 p equ pid+2
space equ p+4 status equ p+4
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc lda argc
dec a dec a
bne getit bne getit
@@ -1389,8 +1414,9 @@ whoashit ldx #^err01
nojob ldx #^err03 nojob ldx #^err03
lda #err03 lda #err03
puterr jsr errputs puterr jsr errputs
inc status Return status = 1
done return 2:#0 done return 2:status
usage dc c'Usage: bg [%job | pid]',h'0d00' usage dc c'Usage: bg [%job | pid]',h'0d00'
err01 dc c'bg: No job to background.',h'0d00' err01 dc c'bg: No job to background.',h'0d00'
@@ -1412,10 +1438,12 @@ stop START
pid equ 0 pid equ 0
p equ pid+2 p equ pid+2
space equ p+4 status equ p+4
space equ status+4
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
stz status
lda argc lda argc
dec a dec a
bne getit bne getit
@@ -1478,8 +1506,9 @@ whoashit ldx #^err01
nojob ldx #^err03 nojob ldx #^err03
lda #err03 lda #err03
puterr jsr errputs puterr jsr errputs
inc status Return status = 1.
done return 2:#0 done return 2:status
usage dc c'Usage: stop [%job | pid]',h'0d00' usage dc c'Usage: stop [%job | pid]',h'0d00'
err01 dc c'stop: No job to stop.',h'0d00' err01 dc c'stop: No job to stop.',h'0d00'

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: orca.asm,v 1.6 1998/09/08 16:53:12 tribby Exp $ * $Id: orca.asm,v 1.7 1998/12/21 23:57:07 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -62,7 +62,8 @@ space equ outPath+4
lda #enofile no filename specified lda #enofile no filename specified
jsr errputs jsr errputs
lda #1 lda #1
bra seterr sta retval
jmp donedealloc
; Allocate memory for sFile, inPath, and outPath ; Allocate memory for sFile, inPath, and outPath

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: shell.asm,v 1.7 1998/10/26 17:04:51 tribby Exp $ * $Id: shell.asm,v 1.8 1998/12/21 23:57:07 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -207,7 +207,8 @@ fastskip2 anop
bne didit bne didit
jsr readterm jsr readterm
didit anop didit anop
jsl hashpath Hash $PATH. 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,hash_print Set hash print flag.
; ;

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: shellutil.asm,v 1.6 1998/09/08 16:53:13 tribby Exp $ * $Id: shellutil.asm,v 1.7 1998/12/21 23:57:08 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -19,6 +19,57 @@
* 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:
*
* tolower Convert the accumulator to lower case
* {accumulator = character}
* jsr tolower
* {if acc was uppercase it's now lowercase; else no change}
*
* toslash Convert ':' to '/'
* {accumulator = character}
* jsr toslash
* {if acc was ':', it's now '/'; otherwise no change}
*
* lowercstr Convert a c string to lower case
* {push address of c string on stack}
* jsr lowercstr
*
* cstrlen Get the length of a c string
* {push address of c string on stack}
* jsr cstrlen
* {return with len of string in acc}
*
* copycstr Copy one string to another. Assumes an alloccstr has been
* performed on destination.
*
* cmpcstr Compare two c strings. Return 0 if equal, -1 if less than,
* +1 if greater
*
* cmpdcstr Compare two downshifted c strings. Return 0 if equal,
* -1 if less than, +1 if greater
*
* c2gsstr Allocate memory, then convert a c string to a GS/OS string
* (caller must dispose when done)
*
* catcstr Takes two strings, concats into a newly created string.
*
* nullfree Call ~DISPOSE if pointer is not NULL
*
* newlineX Print a carriage return and a newline, unless "newline" shell
* var is set.
*
* getenv Get value of indicated environment variable; pass in addr of a
* GS/OS string, and pass back addr of allocated GS/OS result
* buffer (with null byte added at end).
* subroutine (4:var)
* return 4:ptr
*
* rmemcpy
* subroutine (2:num,4:src,4:dest)
*
************************************************************************** **************************************************************************
mcopy /obj/gno/bin/gsh/shellutil.mac mcopy /obj/gno/bin/gsh/shellutil.mac
@@ -479,7 +530,7 @@ newline ENTRY
* is written in assembly! :) * is written in assembly! :)
* *
* For gsh 2.0: pass in addr of a GS/OS string, and pass back addr of * For gsh 2.0: pass in addr of a GS/OS string, and pass back addr of
* allocated GS/OS result buffer (with null word added at end), not c-strings. * allocated GS/OS result buffer (with null byte added at end), not c-strings.
* *
************************************************************************** **************************************************************************
@@ -582,11 +633,17 @@ TempRBlen ds 2 Value's length returned here.
END END
**************************************************************************
*
* Copy src bytes to destination address
*
**************************************************************************
rmemcpy START rmemcpy START
subroutine (2:num,4:src,4:dest),0 subroutine (2:num,4:src,4:dest),0
ldy num ldy num Get length of src.
beq done beq done Done if == 0.
tya tya
dey dey
bit #1 bit #1

View File

@@ -7,7 +7,7 @@
* Tim Meekins * Tim Meekins
* Derek Taubert * Derek Taubert
* *
* $Id: shellvar.asm,v 1.6 1998/09/08 16:53:13 tribby Exp $ * $Id: shellvar.asm,v 1.7 1998/12/21 23:57:08 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -20,6 +20,20 @@
* 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:
*
* updatevars subroutine (4:var,2:flag),space ;flag 1: set, 0: unset
* InitVars jsr without any parameters
*
* Remainder are interfaces to builtin commands with interface
* subroutine (4:argv,2:argc)
* returns status in accumulator
* export
* set (setenv is alternate entry point)
* unset
*
************************************************************************** **************************************************************************
mcopy /obj/gno/bin/gsh/shellvar.mac mcopy /obj/gno/bin/gsh/shellvar.mac
@@ -46,7 +60,8 @@ arg equ 1
valbuf equ arg+4 valbuf equ arg+4
varbuf equ valbuf+4 varbuf equ valbuf+4
exflag equ varbuf+4 exflag equ varbuf+4
space equ exflag+2 status equ exflag+2
space equ status+2
argc equ space+3 argc equ space+3
argv equ argc+2 argv equ argc+2
end equ argv+4 end equ argv+4
@@ -90,6 +105,8 @@ setenv ENTRY
; ;
startcmd anop startcmd anop
stz status
lda argc If no parameter provided, lda argc If no parameter provided,
dec a dec a
beq showvars list all variables. beq showvars list all variables.
@@ -112,6 +129,7 @@ startcmd anop
showusage ldx #^Usage showusage ldx #^Usage
lda #Usage lda #Usage
jsr errputs jsr errputs
inc status Return status = 1.
jmp exit jmp exit
; ;
@@ -133,7 +151,8 @@ showvars anop
jsl nullfree jsl nullfree
svwhoops ld2 $201,ErrError report memory error svwhoops ld2 $201,ErrError report memory error
ErrorGS Err ErrorGS Err
jmp exit and exit. inc status set return status = 1
jmp exit and exit.
startshow anop startshow anop
lda #1022 Store buffer len == 1022 in value lda #1022 Store buffer len == 1022 in value
@@ -225,6 +244,7 @@ unixstyle cpy #0
ldx #^error1 ldx #^error1
lda #error1 Print error message: lda #error1 Print error message:
jsr errputs 'Variable not specified' jsr errputs 'Variable not specified'
inc status Return status = 1.
jmp doneset jmp doneset
unix0 short a Store '\0' on unix0 short a Store '\0' on
lda #0 on top of '=' lda #0 on top of '='
@@ -304,6 +324,7 @@ showonevar anop
notdef ldx #^error2 'Variable not defined' notdef ldx #^error2 'Variable not defined'
lda #error2 lda #error2
jsr errputs jsr errputs
inc status Return status = 1.
bra doneone bra doneone
def ldx RSexport X = export flag. def ldx RSexport X = export flag.
@@ -320,7 +341,8 @@ doneone anop
doneset unlock setmutex doneset unlock setmutex
exit lda space exit ldy status
lda space
sta end-3 sta end-3
lda space+1 lda space+1
sta end-2 sta end-2
@@ -329,7 +351,7 @@ exit lda space
adc #end-4 adc #end-4
tcs tcs
lda #0 Return status = 0. tya Return status
rtl rtl
@@ -443,23 +465,19 @@ ErrError ds 2 Error number
export START export START
space equ 1 status equ 0
argc equ space+3 space equ status+2
argv equ argc+2
end equ argv+4
; subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
tsc
phd
tcd
stz status
lda argc Get parameter count. lda argc Get parameter count.
dec a If < 1 dec a If < 1
bne loop bne loop
ldx #^Usage Print usage string ldx #^Usage Print usage string
lda #Usage lda #Usage
jsr errputs jsr errputs
inc status
bra done and terminate. bra done and terminate.
; ;
@@ -490,19 +508,7 @@ loop anop
bra loop bra loop
done lda space done return 2:status
sta end-3
lda space+1
sta end-2
pld
tsc
clc
adc #end-4
tcs
lda #0
rtl
expmutex key expmutex key
@@ -529,16 +535,12 @@ Usage dc c'Usage: export var ...',h'0d00'
unset START unset START
space equ 1 status equ 0
argc equ space+3 space equ status+2
argv equ argc+2
end equ argv+4
; subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
tsc stz status
phd
tcd
lda argc Get parameter count. lda argc Get parameter count.
dec a If < 1 dec a If < 1
@@ -546,7 +548,8 @@ end equ argv+4
ldx #^Usage Print usage string ldx #^Usage Print usage string
lda #Usage lda #Usage
jsr errputs jsr errputs
bra done and terminate. inc status set return status = 1
bra done and terminate.
; ;
; Loop to process all the variables to export ; Loop to process all the variables to export
@@ -584,19 +587,7 @@ loop anop
bra loop bra loop
done lda space done return 2:status
sta end-3
lda space+1
sta end-2
pld
tsc
clc
adc #end-4
tcs
lda #0
rtl
unsmutex key unsmutex key

View File

@@ -6,7 +6,7 @@
* Jawaid Bazyar * Jawaid Bazyar
* Tim Meekins * Tim Meekins
* *
* $Id: term.asm,v 1.7 1998/10/26 17:04:51 tribby Exp $ * $Id: term.asm,v 1.8 1998/12/21 23:57:08 tribby Exp $
* *
************************************************************************** **************************************************************************
* *
@@ -501,13 +501,27 @@ tset START
using global using global
space equ 0 status equ 0
space equ status+2
subroutine (4:argv,2:argc),space subroutine (4:argv,2:argc),space
jsr readterm stz status
lda argc
dec a
beq doterm
return ldx #^Usage
lda #Usage
jsr errputs
inc status Return status = 1.
bra exit
doterm jsr readterm
exit return 2:status
usage dc c'Usage: tset',h'0d00'
END END