1997-11-18 05:31:00 +00:00
|
|
|
**************************************************************************
|
|
|
|
*
|
|
|
|
* The GNO Shell Project
|
|
|
|
*
|
|
|
|
* Developed by:
|
|
|
|
* Jawaid Bazyar
|
|
|
|
* Tim Meekins
|
|
|
|
*
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
* $Id: alias.asm,v 1.8 1998/12/31 18:29:11 tribby Exp $
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
*
|
1997-11-18 05:31:00 +00:00
|
|
|
**************************************************************************
|
|
|
|
*
|
|
|
|
* ALIAS.ASM
|
|
|
|
* By Tim Meekins
|
1998-08-03 17:30:30 +00:00
|
|
|
* Modified by Dave Tribby for GNO 2.0.6
|
1997-11-18 05:31:00 +00:00
|
|
|
*
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
* Note: text set up for tabs at col 16, 22, 41, 49, 57, 65
|
|
|
|
* | | | | | |
|
|
|
|
* ^ ^ ^ ^ ^ ^
|
|
|
|
**************************************************************************
|
|
|
|
*
|
|
|
|
* Interfaces defined in this file:
|
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* alias subroutine (4:argv,2:argc)
|
|
|
|
* Returns with status=0 in Accumulator
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* unalias subroutine (4:argv,2:argc)
|
1998-12-21 23:57:08 +00:00
|
|
|
* return 2:status
|
1998-09-08 16:53:14 +00:00
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* initalias jsr/rts with no parameters
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* expandalias subroutine (4:cmd)
|
|
|
|
* return 4:buf
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* addalias subroutine (4:aliasname,4:aliasval)
|
|
|
|
* return
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* removealias subroutine (4:aliasname)
|
|
|
|
* return
|
1998-09-08 16:53:14 +00:00
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* findalias subroutine (4:aliasname),space
|
|
|
|
* return 4:value
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* startalias jsl/rtl with no parameters
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
*
|
1998-07-20 16:23:11 +00:00
|
|
|
* nextalias subroutine (4:p)
|
|
|
|
* return 2:hashvalz
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
*
|
|
|
|
*
|
1997-11-18 05:31:00 +00:00
|
|
|
**************************************************************************
|
|
|
|
|
1998-04-24 15:38:47 +00:00
|
|
|
mcopy /obj/gno/bin/gsh/alias.mac
|
|
|
|
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
dummyalias start ; ends up in root
|
1998-04-24 15:38:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
setcom 60
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
VTABSIZE gequ 17
|
|
|
|
|
|
|
|
**************************************************************************
|
|
|
|
*
|
|
|
|
* ALIAS: builtin command
|
|
|
|
* syntax: alias [name [def]]
|
|
|
|
*
|
|
|
|
* set aliases
|
|
|
|
*
|
|
|
|
**************************************************************************
|
|
|
|
|
|
|
|
alias START
|
|
|
|
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
using AliasData
|
|
|
|
|
1997-11-18 05:31:00 +00:00
|
|
|
arg equ 1
|
|
|
|
space equ arg+4
|
|
|
|
argc equ space+3
|
|
|
|
argv equ argc+2
|
|
|
|
end equ argv+4
|
|
|
|
|
|
|
|
; subroutine (4:argv,2:argc),space
|
|
|
|
|
|
|
|
tsc
|
|
|
|
sec
|
|
|
|
sbc #space-1
|
|
|
|
tcs
|
|
|
|
phd
|
|
|
|
tcd
|
|
|
|
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
lock AliasMutex
|
1998-07-20 16:23:11 +00:00
|
|
|
lda argc How many arguments were provided?
|
1997-11-18 05:31:00 +00:00
|
|
|
dec a
|
1998-07-20 16:23:11 +00:00
|
|
|
beq showall None -- show all alias names.
|
1997-11-18 05:31:00 +00:00
|
|
|
dec a
|
1998-07-20 16:23:11 +00:00
|
|
|
beq showone One -- show a single name.
|
|
|
|
jmp setalias More -- set an alias.
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-07-20 16:23:11 +00:00
|
|
|
;
|
|
|
|
; Show all aliases
|
|
|
|
;
|
1997-11-18 05:31:00 +00:00
|
|
|
showall jsl startalias
|
|
|
|
showloop jsl nextalias
|
|
|
|
sta arg
|
|
|
|
stx arg+2
|
|
|
|
ora arg+2
|
|
|
|
beq noshow
|
|
|
|
ldy #6
|
|
|
|
lda [arg],y
|
|
|
|
tax
|
|
|
|
ldy #4
|
|
|
|
lda [arg],y
|
|
|
|
jsr puts
|
|
|
|
lda #':'
|
|
|
|
jsr putchar
|
|
|
|
lda #' '
|
|
|
|
jsr putchar
|
|
|
|
ldy #10
|
|
|
|
lda [arg],y
|
|
|
|
tax
|
|
|
|
ldy #8
|
|
|
|
lda [arg],y
|
|
|
|
jsr puts
|
|
|
|
jsr newline
|
|
|
|
bra showloop
|
|
|
|
|
|
|
|
noshow jmp exit
|
|
|
|
|
1998-07-20 16:23:11 +00:00
|
|
|
;
|
|
|
|
; Show a single alias
|
|
|
|
;
|
1997-11-18 05:31:00 +00:00
|
|
|
showone ldy #4+2
|
|
|
|
lda [argv],y
|
|
|
|
tax
|
|
|
|
pha ;for findalias
|
|
|
|
ldy #4
|
|
|
|
lda [argv],y
|
|
|
|
pha
|
1998-07-20 16:23:11 +00:00
|
|
|
jsr puts Print name.
|
|
|
|
lda #':' Print ": ".
|
1997-11-18 05:31:00 +00:00
|
|
|
jsr putchar
|
|
|
|
lda #' '
|
|
|
|
jsr putchar
|
|
|
|
jsl findalias
|
|
|
|
sta arg
|
|
|
|
stx arg+2
|
|
|
|
ora arg+2
|
|
|
|
beq notthere
|
|
|
|
lda arg
|
1998-07-20 16:23:11 +00:00
|
|
|
jsr puts Print alias value.
|
|
|
|
jsr newline Print newline.
|
|
|
|
jmp exit All done.
|
|
|
|
|
|
|
|
notthere ldx #^noalias Print message:
|
|
|
|
lda #noalias 'Alias not defined'
|
1997-11-18 05:31:00 +00:00
|
|
|
jsr puts
|
|
|
|
jmp exit
|
|
|
|
|
1998-07-20 16:23:11 +00:00
|
|
|
;
|
|
|
|
; Set an alias name
|
|
|
|
;
|
1997-11-18 05:31:00 +00:00
|
|
|
setalias ldy #4+2 ;put alias name on stack
|
|
|
|
lda [argv],y
|
|
|
|
pha
|
|
|
|
ldy #4
|
|
|
|
lda [argv],y
|
|
|
|
pha
|
|
|
|
|
|
|
|
ph4 #2
|
1998-08-03 17:30:30 +00:00
|
|
|
~NEW
|
1997-11-18 05:31:00 +00:00
|
|
|
sta arg
|
|
|
|
stx arg+2
|
|
|
|
lda #0
|
|
|
|
sta [arg]
|
|
|
|
|
|
|
|
add2 argv,#8,argv
|
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
dec2 argc
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
buildalias lda argc
|
1997-11-18 05:31:00 +00:00
|
|
|
beq setit
|
|
|
|
|
|
|
|
pei (arg+2)
|
|
|
|
pei (arg)
|
|
|
|
pei (arg+2)
|
|
|
|
pei (arg)
|
|
|
|
ldy #2
|
|
|
|
lda [argv],y
|
|
|
|
pha
|
|
|
|
lda [argv]
|
|
|
|
pha
|
1998-09-08 16:53:14 +00:00
|
|
|
jsr catcstr
|
1997-11-18 05:31:00 +00:00
|
|
|
stx arg+2
|
|
|
|
sta arg
|
|
|
|
jsl nullfree
|
|
|
|
|
|
|
|
pei (arg+2)
|
|
|
|
pei (arg)
|
|
|
|
pei (arg+2)
|
|
|
|
pei (arg)
|
|
|
|
ph4 #spacestr
|
1998-09-08 16:53:14 +00:00
|
|
|
jsr catcstr
|
1997-11-18 05:31:00 +00:00
|
|
|
stx arg+2
|
|
|
|
sta arg
|
|
|
|
jsl nullfree
|
|
|
|
|
|
|
|
dec argc
|
|
|
|
add2 argv,#4,argv
|
|
|
|
bra buildalias
|
|
|
|
|
|
|
|
setit pei (arg+2)
|
|
|
|
pei (arg)
|
|
|
|
jsl addalias
|
|
|
|
pei (arg+2)
|
|
|
|
pei (arg)
|
|
|
|
jsl nullfree
|
|
|
|
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
exit unlock AliasMutex
|
|
|
|
lda space
|
1997-11-18 05:31:00 +00:00
|
|
|
sta end-3
|
|
|
|
lda space+1
|
|
|
|
sta end-2
|
|
|
|
pld
|
|
|
|
tsc
|
|
|
|
clc
|
|
|
|
adc #end-4
|
|
|
|
tcs
|
|
|
|
|
1998-07-20 16:23:11 +00:00
|
|
|
lda #0 Return status always 0.
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
rtl
|
|
|
|
|
|
|
|
noalias dc c'Alias not defined',h'0d00'
|
|
|
|
spacestr dc c' ',h'00'
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
**************************************************************************
|
|
|
|
*
|
|
|
|
* UNALIAS: builtin command
|
|
|
|
* syntax: unalias [var ...]
|
|
|
|
*
|
|
|
|
* removes each alias listed
|
|
|
|
*
|
|
|
|
**************************************************************************
|
|
|
|
|
|
|
|
unalias START
|
|
|
|
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
using AliasData
|
|
|
|
|
1998-12-21 23:57:08 +00:00
|
|
|
status equ 0
|
|
|
|
space equ status+2
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-12-21 23:57:08 +00:00
|
|
|
subroutine (4:argv,2:argc),space
|
1997-11-18 05:31:00 +00:00
|
|
|
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
lock AliasMutex
|
|
|
|
|
1998-12-21 23:57:08 +00:00
|
|
|
stz status
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
lda argc
|
|
|
|
dec a
|
|
|
|
bne loop
|
|
|
|
|
|
|
|
ldx #^Usage
|
|
|
|
lda #USage
|
|
|
|
jsr errputs
|
1998-12-21 23:57:08 +00:00
|
|
|
inc status Return status = 1.
|
1997-11-18 05:31:00 +00:00
|
|
|
bra done
|
|
|
|
|
|
|
|
loop add2 argv,#4,argv
|
|
|
|
dec argc
|
|
|
|
beq done
|
|
|
|
|
|
|
|
ldy #2
|
|
|
|
lda [argv],y
|
|
|
|
pha
|
|
|
|
lda [argv]
|
|
|
|
pha
|
|
|
|
jsl removealias
|
|
|
|
|
|
|
|
bra loop
|
|
|
|
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
done unlock AliasMutex
|
|
|
|
return 2:status
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
Usage dc c'Usage: unalias name ...',h'0d00'
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Init alias table
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
initalias START
|
|
|
|
|
|
|
|
using AliasData
|
|
|
|
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
; Set all entries in AliasTable to 0
|
|
|
|
|
1997-11-18 05:31:00 +00:00
|
|
|
lda #0
|
|
|
|
ldy #VTABSIZE
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
tax
|
1997-11-18 05:31:00 +00:00
|
|
|
yahaha sta AliasTable,x
|
|
|
|
inx2
|
|
|
|
sta AliasTable,x
|
|
|
|
inx2
|
|
|
|
dey
|
|
|
|
bne yahaha
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
END
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Expand alias
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
expandalias START
|
1998-09-08 16:53:14 +00:00
|
|
|
|
1997-11-18 05:31:00 +00:00
|
|
|
outbuf equ 0
|
|
|
|
sub equ outbuf+4
|
|
|
|
word equ sub+4
|
|
|
|
buf equ word+4
|
|
|
|
space equ buf+4
|
|
|
|
|
|
|
|
subroutine (4:cmd),space
|
|
|
|
|
|
|
|
ph4 #1024
|
1998-08-03 17:30:30 +00:00
|
|
|
~NEW
|
1997-11-18 05:31:00 +00:00
|
|
|
stx buf+2
|
|
|
|
sta buf
|
|
|
|
stx outbuf+2
|
|
|
|
sta outbuf
|
|
|
|
jsl alloc1024
|
|
|
|
stx word+2
|
|
|
|
sta word
|
|
|
|
lda #0
|
1998-09-08 16:53:14 +00:00
|
|
|
sta [buf] In case we're called with empty string
|
|
|
|
sta [word]
|
1997-11-18 05:31:00 +00:00
|
|
|
;
|
|
|
|
; eat leading spaces
|
|
|
|
;
|
|
|
|
eatleader lda [cmd]
|
|
|
|
and #$FF
|
|
|
|
jeq done
|
|
|
|
cmp #' '
|
|
|
|
bne getword
|
|
|
|
inc cmd
|
|
|
|
sta [outbuf]
|
|
|
|
inc outbuf
|
|
|
|
bra eatleader
|
|
|
|
;
|
|
|
|
; find the leading word
|
|
|
|
;
|
|
|
|
getword short a
|
|
|
|
ldy #0
|
|
|
|
makeword lda [cmd],y
|
|
|
|
if2 @a,eq,#0,gotword
|
|
|
|
if2 @a,eq,#' ',gotword
|
|
|
|
if2 @a,eq,#';',gotword
|
|
|
|
if2 @a,eq,#'&',gotword
|
|
|
|
if2 @a,eq,#'|',gotword
|
|
|
|
if2 @a,eq,#'>',gotword
|
|
|
|
if2 @a,eq,#'<',gotword
|
|
|
|
if2 @a,eq,#13,gotword
|
|
|
|
if2 @a,eq,#9,gotword
|
|
|
|
if2 @a,eq,#10,gotword
|
|
|
|
sta [word],y
|
|
|
|
iny
|
|
|
|
bra makeword
|
|
|
|
;
|
|
|
|
; we got a word, now check if it's an alias
|
|
|
|
;
|
|
|
|
gotword lda #0
|
|
|
|
sta [word],y
|
|
|
|
long a
|
|
|
|
add2 @y,cmd,cmd
|
|
|
|
phy
|
|
|
|
pei (word+2)
|
|
|
|
pei (word)
|
|
|
|
jsl findalias
|
|
|
|
sta sub
|
|
|
|
stx sub+2
|
|
|
|
ora sub+2
|
|
|
|
beq noalias
|
|
|
|
;
|
|
|
|
; expand it, if you hadn't figured it out for yourself by now.
|
|
|
|
;
|
|
|
|
pla
|
|
|
|
ldy #0
|
|
|
|
putalias lda [sub],y
|
|
|
|
and #$FF
|
|
|
|
beq next
|
|
|
|
sta [outbuf]
|
|
|
|
inc outbuf
|
|
|
|
iny
|
|
|
|
bra putalias
|
|
|
|
;
|
|
|
|
; no alias, so just copy the original string
|
|
|
|
;
|
|
|
|
noalias plx
|
|
|
|
beq next
|
|
|
|
ldy #0
|
|
|
|
noalias2 lda [word],y
|
|
|
|
sta [outbuf]
|
|
|
|
inc outbuf
|
|
|
|
iny
|
|
|
|
dex
|
|
|
|
bne noalias2
|
|
|
|
;
|
|
|
|
; the alias is expanded, now copy until we reach the next command
|
|
|
|
;
|
|
|
|
next lda [cmd]
|
|
|
|
inc cmd
|
|
|
|
sta [outbuf]
|
|
|
|
inc outbuf
|
|
|
|
and #$FF
|
|
|
|
beq done
|
|
|
|
if2 @a,eq,#13,nextalias
|
|
|
|
if2 @a,eq,#';',nextalias
|
|
|
|
if2 @a,eq,#'&',nextalias
|
|
|
|
if2 @a,eq,#'|',nextalias
|
1998-09-08 16:53:14 +00:00
|
|
|
if2 @a,eq,#'\',backstabber
|
1997-11-18 05:31:00 +00:00
|
|
|
if2 @a,eq,#"'",singquoter
|
|
|
|
if2 @a,eq,#'"',doubquoter
|
|
|
|
bra next
|
1998-07-20 16:23:11 +00:00
|
|
|
;
|
|
|
|
; "\" found
|
|
|
|
;
|
1997-11-18 05:31:00 +00:00
|
|
|
backstabber lda [cmd]
|
|
|
|
inc cmd
|
|
|
|
sta [outbuf]
|
|
|
|
inc outbuf
|
|
|
|
and #$FF
|
|
|
|
beq done
|
|
|
|
bra next
|
1998-07-20 16:23:11 +00:00
|
|
|
;
|
|
|
|
; "'" found
|
|
|
|
;
|
1997-11-18 05:31:00 +00:00
|
|
|
singquoter lda [cmd]
|
|
|
|
inc cmd
|
|
|
|
sta [outbuf]
|
|
|
|
inc outbuf
|
|
|
|
and #$FF
|
|
|
|
beq done
|
|
|
|
if2 @a,ne,#"'",singquoter
|
|
|
|
bra next
|
1998-07-20 16:23:11 +00:00
|
|
|
;
|
|
|
|
; '"' found
|
|
|
|
;
|
1997-11-18 05:31:00 +00:00
|
|
|
doubquoter lda [cmd]
|
|
|
|
inc cmd
|
|
|
|
sta [outbuf]
|
|
|
|
inc outbuf
|
|
|
|
and #$FF
|
|
|
|
beq done
|
1998-07-20 16:23:11 +00:00
|
|
|
if2 @a,ne,#'"',doubquoter
|
1997-11-18 05:31:00 +00:00
|
|
|
bra next
|
1998-07-20 16:23:11 +00:00
|
|
|
|
|
|
|
;
|
|
|
|
; ";", "|", or "&" found: it's another command
|
|
|
|
;
|
1997-11-18 05:31:00 +00:00
|
|
|
nextalias jmp eatleader
|
|
|
|
|
|
|
|
done ldx word+2
|
|
|
|
lda word
|
|
|
|
jsl free1024
|
|
|
|
|
|
|
|
return 4:buf
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Add alias to table
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
addalias START
|
1998-09-08 16:53:14 +00:00
|
|
|
|
1997-11-18 05:31:00 +00:00
|
|
|
using AliasData
|
|
|
|
|
|
|
|
tmp equ 0
|
|
|
|
ptr equ tmp+4
|
|
|
|
hashval equ ptr+4
|
|
|
|
space equ hashval+4
|
|
|
|
|
|
|
|
subroutine (4:aliasname,4:aliasval),space
|
|
|
|
|
|
|
|
pei (aliasname+2)
|
|
|
|
pei (aliasname)
|
|
|
|
jsl hashalias
|
|
|
|
sta hashval
|
|
|
|
|
|
|
|
tax
|
|
|
|
lda AliasTable,x
|
|
|
|
sta ptr
|
|
|
|
lda AliasTable+2,x
|
|
|
|
sta ptr+2
|
|
|
|
|
|
|
|
search lda ptr
|
Major changes to gsh with this checkin:
* When ~ is parsed and next character is a delimiter, make sure contents
of expanded $HOME match the user's delimiter.
* When wildcard patterns don't match, rather than terminating the command
gsh now prints "No match: <pattern> ignored" and passes the command line
minus the unmatched patterns on to be executed.
* Modified echo command so it doesn't add a blank to the end.
* Make "clear" and "source" built-ins non-forked commands. Unforking
"source" allows prefixes to be set in files that are sourced.
* Add loop to parse a single command (removing leading whitespace) before
sending it off to be expanded and executed. Skip null lines and comments
at this level. This allows later commands that depend upon variables set
in the 1st command to work; e.g.: set t_num=1 ; echo "Test number $t_num"
Also fixes problems seen when tab was first character of multiple lines.
* Initialize environment variable flags at startup (for echo, nodirexec,
nonewline, noglob, nobeep, pushdsilent, term, and ignoreeof). Set
flag when env var is set in upper or lower case (formerly, only worked
with lower case).
* Lots of places two-word addresses are incremented using inc, without
checking for overflow into the high-order word. As these are discovered,
they are changed to use adc on both words.
See file UpdateLog for detailed list of changes.
1998-06-30 17:26:04 +00:00
|
|
|
ora ptr+2
|
1997-11-18 05:31:00 +00:00
|
|
|
beq notfound
|
|
|
|
ldy #4
|
|
|
|
lda [ptr],y
|
|
|
|
tax
|
|
|
|
ldy #4+2
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
phx
|
|
|
|
pei (aliasname+2)
|
|
|
|
pei (aliasname)
|
|
|
|
jsr cmpcstr
|
|
|
|
jeq replace
|
|
|
|
ldy #2
|
|
|
|
lda [ptr]
|
|
|
|
tax
|
|
|
|
lda [ptr],y
|
|
|
|
sta ptr+2
|
|
|
|
stx ptr
|
|
|
|
bra search
|
|
|
|
|
|
|
|
replace ldy #8+2
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
ldy #8
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
jsl nullfree
|
|
|
|
pei (aliasval+2)
|
1998-09-08 16:53:14 +00:00
|
|
|
pei (aliasval)
|
1997-11-18 05:31:00 +00:00
|
|
|
jsr cstrlen
|
|
|
|
inc a
|
|
|
|
pea 0
|
|
|
|
pha
|
1998-08-03 17:30:30 +00:00
|
|
|
~NEW
|
1997-11-18 05:31:00 +00:00
|
|
|
sta tmp
|
|
|
|
stx tmp+2
|
|
|
|
ldy #8
|
|
|
|
sta [ptr],y
|
|
|
|
ldy #8+2
|
|
|
|
txa
|
|
|
|
sta [ptr],y
|
|
|
|
pei (aliasval+2)
|
|
|
|
pei (aliasval)
|
|
|
|
pei (tmp+2)
|
|
|
|
pei (tmp)
|
|
|
|
jsr copycstr
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
jmp done
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
notfound ph4 #4*3
|
1998-08-03 17:30:30 +00:00
|
|
|
~NEW
|
1997-11-18 05:31:00 +00:00
|
|
|
sta ptr
|
|
|
|
stx ptr+2
|
|
|
|
ldy #2
|
|
|
|
ldx hashval
|
|
|
|
lda AliasTable,x
|
|
|
|
sta [ptr]
|
|
|
|
lda AliasTable+2,x
|
|
|
|
sta [ptr],y
|
|
|
|
pei (aliasname+2)
|
1998-09-08 16:53:14 +00:00
|
|
|
pei (aliasname)
|
1997-11-18 05:31:00 +00:00
|
|
|
jsr cstrlen
|
|
|
|
inc a
|
|
|
|
pea 0
|
|
|
|
pha
|
1998-08-03 17:30:30 +00:00
|
|
|
~NEW
|
1997-11-18 05:31:00 +00:00
|
|
|
sta tmp
|
|
|
|
stx tmp+2
|
|
|
|
ldy #4
|
|
|
|
sta [ptr],y
|
|
|
|
ldy #4+2
|
|
|
|
txa
|
|
|
|
sta [ptr],y
|
|
|
|
pei (aliasname+2)
|
|
|
|
pei (aliasname)
|
|
|
|
pei (tmp+2)
|
|
|
|
pei (tmp)
|
|
|
|
jsr copycstr
|
|
|
|
pei (aliasval+2)
|
1998-09-08 16:53:14 +00:00
|
|
|
pei (aliasval)
|
1997-11-18 05:31:00 +00:00
|
|
|
jsr cstrlen
|
|
|
|
inc a
|
|
|
|
pea 0
|
|
|
|
pha
|
1998-08-03 17:30:30 +00:00
|
|
|
~NEW
|
1997-11-18 05:31:00 +00:00
|
|
|
sta tmp
|
|
|
|
stx tmp+2
|
|
|
|
ldy #8
|
|
|
|
sta [ptr],y
|
|
|
|
ldy #8+2
|
|
|
|
txa
|
|
|
|
sta [ptr],y
|
|
|
|
pei (aliasval+2)
|
|
|
|
pei (aliasval)
|
|
|
|
pei (tmp+2)
|
|
|
|
pei (tmp)
|
|
|
|
jsr copycstr
|
|
|
|
ldx hashval
|
|
|
|
lda ptr
|
|
|
|
sta AliasTable,x
|
|
|
|
lda ptr+2
|
|
|
|
sta AliasTable+2,x
|
1998-09-08 16:53:14 +00:00
|
|
|
|
1997-11-18 05:31:00 +00:00
|
|
|
done return
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Remove an alias
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
removealias START
|
|
|
|
|
|
|
|
using AliasData
|
|
|
|
|
|
|
|
oldptr equ 0
|
|
|
|
ptr equ oldptr+4
|
|
|
|
space equ ptr+4
|
|
|
|
|
|
|
|
subroutine (4:aliasname),space
|
|
|
|
|
|
|
|
pei (aliasname+2)
|
|
|
|
pei (aliasname)
|
|
|
|
jsl hashalias
|
|
|
|
tax
|
|
|
|
lda AliasTable,x
|
|
|
|
sta ptr
|
|
|
|
lda AliasTable+2,x
|
|
|
|
sta ptr+2
|
|
|
|
lda #^Aliastable
|
|
|
|
sta oldptr+2
|
|
|
|
clc
|
|
|
|
txa
|
|
|
|
adc #AliasTable
|
|
|
|
sta oldptr
|
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
searchloop ora2 ptr,ptr+2,@a
|
|
|
|
beq done
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
ldy #4+2
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
ldy #4
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
pei (aliasname+2)
|
|
|
|
pei (aliasname)
|
|
|
|
jsr cmpcstr
|
|
|
|
beq foundit
|
|
|
|
mv4 ptr,oldptr
|
|
|
|
ldy #2
|
|
|
|
lda [ptr],y
|
|
|
|
tax
|
|
|
|
lda [ptr]
|
|
|
|
sta ptr
|
|
|
|
stx ptr+2
|
|
|
|
bra searchloop
|
|
|
|
|
|
|
|
foundit ldy #2
|
|
|
|
lda [ptr],y
|
|
|
|
sta [oldptr],y
|
|
|
|
lda [ptr]
|
|
|
|
sta [oldptr]
|
|
|
|
ldy #4+2
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
ldy #4
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
jsl nullfree
|
|
|
|
ldy #8+2
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
ldy #8
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
jsl nullfree
|
|
|
|
pei (ptr+2)
|
|
|
|
pei (ptr)
|
|
|
|
jsl nullfree
|
1998-09-08 16:53:14 +00:00
|
|
|
|
1997-11-18 05:31:00 +00:00
|
|
|
done return
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Find an alias
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
findalias START
|
|
|
|
|
|
|
|
using AliasData
|
|
|
|
|
|
|
|
ptr equ 0
|
|
|
|
value equ ptr+4
|
|
|
|
space equ value+4
|
|
|
|
|
|
|
|
subroutine (4:aliasname),space
|
|
|
|
|
|
|
|
stz value
|
|
|
|
stz value+2
|
|
|
|
|
|
|
|
pei (aliasname+2)
|
|
|
|
pei (aliasname)
|
|
|
|
jsl hashalias
|
|
|
|
tax
|
|
|
|
lda AliasTable,x
|
|
|
|
sta ptr
|
|
|
|
lda AliasTable+2,x
|
|
|
|
sta ptr+2
|
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
searchloop ora2 ptr,ptr+2,@a
|
|
|
|
beq done
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
ldy #4+2
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
ldy #4
|
|
|
|
lda [ptr],y
|
|
|
|
pha
|
|
|
|
pei (aliasname+2)
|
|
|
|
pei (aliasname)
|
|
|
|
jsr cmpcstr
|
|
|
|
beq foundit
|
|
|
|
ldy #2
|
|
|
|
lda [ptr],y
|
|
|
|
tax
|
|
|
|
lda [ptr]
|
|
|
|
sta ptr
|
|
|
|
stx ptr+2
|
|
|
|
bra searchloop
|
|
|
|
|
|
|
|
foundit ldy #8
|
|
|
|
lda [ptr],y
|
|
|
|
sta value
|
|
|
|
ldy #8+2
|
|
|
|
lda [ptr],y
|
|
|
|
sta value+2
|
|
|
|
|
|
|
|
done return 4:value
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Start alias
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
startalias START
|
|
|
|
|
|
|
|
using AliasData
|
|
|
|
|
|
|
|
stz AliasNum
|
|
|
|
mv4 AliasTable,AliasPtr
|
|
|
|
rtl
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Next alias
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
nextalias START
|
|
|
|
|
|
|
|
using AliasData
|
|
|
|
|
|
|
|
value equ 0
|
|
|
|
space equ value+4
|
|
|
|
|
|
|
|
subroutine (0:fubar),space
|
|
|
|
|
|
|
|
stz value
|
|
|
|
stz value+2
|
|
|
|
puke if2 AliasNum,cs,#VTABSIZE,done
|
|
|
|
|
|
|
|
ora2 AliasPtr,AliasPtr+2,@a
|
|
|
|
bne flush
|
|
|
|
inc AliasNum
|
|
|
|
lda AliasNum
|
|
|
|
asl2 a
|
|
|
|
tax
|
|
|
|
lda AliasTable,x
|
|
|
|
sta AliasPtr
|
|
|
|
lda AliasTable+2,x
|
|
|
|
sta AliasPtr+2
|
|
|
|
bra puke
|
|
|
|
|
|
|
|
flush mv4 AliasPtr,value
|
|
|
|
ldy #2
|
|
|
|
lda [value]
|
|
|
|
sta AliasPtr
|
|
|
|
lda [value],y
|
|
|
|
sta AliasPtr+2
|
|
|
|
|
|
|
|
done return 4:value
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Hash an alias
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
hashalias PRIVATE
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
hashval equ 0
|
|
|
|
space equ hashval+2
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
subroutine (4:p),space
|
|
|
|
|
|
|
|
lda #11
|
|
|
|
sta hashval
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
ldy #0
|
|
|
|
loop asl hashval
|
|
|
|
lda [p],y
|
|
|
|
and #$FF
|
|
|
|
beq done
|
|
|
|
clc
|
|
|
|
adc hashval
|
|
|
|
sta hashval
|
|
|
|
iny
|
|
|
|
bra loop
|
|
|
|
done UDivide (hashval,#VTABSIZE),(@a,@a)
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
asl2 a ;Make it an index.
|
|
|
|
sta hashval
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
return 2:hashval
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
END
|
1997-11-18 05:31:00 +00:00
|
|
|
|
|
|
|
;=========================================================================
|
|
|
|
;
|
|
|
|
; Alias data
|
|
|
|
;
|
|
|
|
;=========================================================================
|
|
|
|
|
|
|
|
AliasData DATA
|
|
|
|
|
|
|
|
AliasNum dc i2'0'
|
|
|
|
AliasPtr dc i4'0'
|
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)
1998-12-31 18:29:14 +00:00
|
|
|
AliasMutex key
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
AliasTable ds VTABSIZE*4
|
1997-11-18 05:31:00 +00:00
|
|
|
|
1998-09-08 16:53:14 +00:00
|
|
|
END
|