mirror of https://github.com/GnoConsortium/gno.git
Changes for gsh version 2.0a1:
Fix PR#50 while maintaining backward compatibility: when new environment variable $KEEPQUOTE is set, use the command line's original single and double quotes unchanged (rather than removing all quotes and adding double quotes as needed). Fix PR#123: do not ignore command line characters following a ";" that was not preceeded by a command. Add signal handler for SIGTTIN (background read attempted from control terminal) that prints a message and quits the shell. This is needed because gsh will sometimes receive such a signal, go into the "suspended" state, and never return to "running" state. Add environment variable $ECHOX to print expanded commands before they are executed.
This commit is contained in:
parent
9aa13dba8f
commit
74f2b97322
|
@ -1,15 +1,27 @@
|
|||
Last updated: Dec. 27, 1998 By: Dave Tribby
|
||||
Last updated: Nov. 26, 1999 By: Dave Tribby
|
||||
|
||||
For more bug reports, see http://www.gno.org/~gno/bugs.html
|
||||
|
||||
Completed items are reported in file UpdateLog.
|
||||
|
||||
|
||||
Allow redirection of built-in commands' I/O even if they aren't forked.
|
||||
Determine why gsh gets SIGTTIN (background read attempted signal) when
|
||||
it executes a very quickly executing child program. Currently gsh
|
||||
quits in order to avoid waiting forever, but that may not always be a
|
||||
good strategy.
|
||||
|
||||
Rather than have each built-in command always be either forked or
|
||||
non-forked, check dynamically and only fork when it's really necessary
|
||||
(background or piped).
|
||||
(background or piped). Something like this:
|
||||
If process is in background (&) or piped (|), then fork.
|
||||
Otherwise: if redirecting I/O, then
|
||||
copy file descriptor(s)
|
||||
open new stdin, stdout, and/or stderr
|
||||
Execute process.
|
||||
If I/O was redirected, then
|
||||
close redirected file(s)
|
||||
reconnect stdin, stdout, and/or stderr
|
||||
Note: routine "command" sets srcfile and dstfile.
|
||||
|
||||
Identify limits built into gsh and how they can be changed; for example,
|
||||
command line cannot expand to > 1024 characters.
|
||||
|
|
|
@ -1,6 +1,34 @@
|
|||
GSH 2.0 UPDATES
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Nov 26 99 [dmt] Cleanup tests directory and update its Makefile.
|
||||
|
||||
Nov 22 99 [dmt] Add environment variable flags $ECHOX and $KEEPQUOTE
|
||||
that modify the behavior of gsh. [shellvar.asm, cmd.asm]
|
||||
If set, $ECHOX causes gsh to echo a single expanded command.
|
||||
(In previous versions of gsh 2.0, this was temporary code
|
||||
that was executed whenever $ECHO was set.)
|
||||
If set, $KEEPQUOTE tells gsh to use the user's original
|
||||
single and double quotes, rather than removing them and
|
||||
adding double quotes as needed. This resolves PR#50 and,
|
||||
if a child program re-parses its parameters, also resolves
|
||||
PR#34 (gsh messes up nested quotes).
|
||||
|
||||
Nov 18 99 [dmt] Fix PR#123: command line parsing ended if a ";"
|
||||
delimited a null command (echo "Test 1" ; ; echo "Test2"
|
||||
would only echo the first string). Modified cmd.asm
|
||||
|
||||
Sep 6 99 [dmt] Add comments to ioctl calls in edit.asm.
|
||||
|
||||
Sep 1 99 [dmt] Added signal handler for SIGTTIN (signal #21, background
|
||||
read attempted from control terminal) that prints a message
|
||||
and quits the shell. This was needed because gsh will sometimes
|
||||
receive such a signal, go into the "suspended" state, and never
|
||||
return to "running" state.
|
||||
|
||||
Feb 11 99 [dmt] Changes to this point checked-in to master archive.
|
||||
Released as version 2.0d10 (displays as 2.0d?)
|
||||
|
||||
Feb 2 99 [dmt] Changed maxline_size from 1024 to 4096.
|
||||
Recode copy loop in expandalias to be more efficient.
|
||||
|
||||
|
@ -26,7 +54,7 @@ Jan 30 99 [dmt] Add check for output buffer overflow when globbing, and
|
|||
to truly eat leading blanks (per comments), and to check for
|
||||
buffer overflow (alias.cmd). (Also tightened up the code.)
|
||||
|
||||
Jan 13 98 [dmt] Changes to this point checked-in to master archive.
|
||||
Jan 13 99 [dmt] Changes to this point checked-in to master archive.
|
||||
Released as version 2.0d9
|
||||
|
||||
Jan 12 99 [dmt] Add debug routine DB~CHKBNK, which causes BRK B0 if
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: cmd.asm,v 1.11 1999/02/08 17:26:50 tribby Exp $
|
||||
* $Id: cmd.asm,v 1.12 1999/11/30 17:53:27 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
|
@ -90,6 +90,8 @@ BADFD gequ -2
|
|||
|
||||
gettoken START
|
||||
|
||||
using vardata
|
||||
|
||||
buf equ 1
|
||||
state equ buf+4
|
||||
ch equ state+2
|
||||
|
@ -198,7 +200,7 @@ neut5 cmp #' ' ;space
|
|||
cmp #9 ;tab
|
||||
jeq loop
|
||||
if2 @a,ne,#'>',neut6
|
||||
lda #GTGT
|
||||
ldx #GTGT
|
||||
bra neut10
|
||||
|
||||
neut4 if2 @a,ne,#13,neut4a ;return
|
||||
|
@ -219,21 +221,26 @@ neut4c lda [buf]
|
|||
neut4d jmp loop
|
||||
|
||||
neut6 if2 @a,ne,#'"',neut7
|
||||
startquote lda #INQUOTE
|
||||
bra neut10
|
||||
startquote ldx #INQUOTE
|
||||
bra chkkeep
|
||||
neut7 if2 @a,ne,#"'",neut8
|
||||
startsingle lda #SINGQUOTE
|
||||
bra neut10
|
||||
startsingle ldx #SINGQUOTE
|
||||
chkkeep ldy varkeepquote ; Is KEEPQUOTE env var set?
|
||||
beq neut10 ; NO: just set the state
|
||||
bra neut9a ; YES: save quote character
|
||||
|
||||
neut8 if2 @a,ne,#'\',neut9
|
||||
lda [buf]
|
||||
and #$FF
|
||||
incad buf
|
||||
if2 @a,eq,#13,neut10a
|
||||
neut9 sta [word] ;default
|
||||
incad word
|
||||
lda #INWORD
|
||||
neut10 sta state
|
||||
neut10a jmp loop
|
||||
|
||||
neut9 ldx #INWORD ; Default
|
||||
|
||||
neut9a sta [word] ; Save character in buffer
|
||||
incad word ; and increment pointer.
|
||||
neut10 stx state ; Set current state.
|
||||
neut10a jmp loop ; Check next character.
|
||||
|
||||
;
|
||||
; CASE GTGT
|
||||
|
@ -256,23 +263,28 @@ gtgt3 incad buf
|
|||
;
|
||||
; CASE INQUOTE
|
||||
;
|
||||
case_inquote if2 ch,ne,#'\',quote2 ;is it a quoted character?
|
||||
lda [buf]
|
||||
incad buf
|
||||
case_inquote if2 ch,ne,#'\',quote2 ; If it's a quoted character,
|
||||
lda [buf] ; load up the next character
|
||||
incad buf ; and bump the pointer.
|
||||
putword sta [word]
|
||||
incad word
|
||||
jmp loop
|
||||
quote2 if2 @a,ne,#'"',putword
|
||||
ld2 INWORD,state
|
||||
jmp loop
|
||||
quote2 if2 @a,ne,#'"',putword
|
||||
bra chkkeep2
|
||||
|
||||
;
|
||||
; CASE SINGLEQUOTE
|
||||
;
|
||||
case_single anop
|
||||
if2 ch,ne,#"'",putword
|
||||
ld2 INWORD,state
|
||||
jmp loop
|
||||
|
||||
; For both ' and ": if KEEPQUOTE env var is set, save quote char in result.
|
||||
chkkeep2 ldy varkeepquote
|
||||
beq nokeep
|
||||
sta [word]
|
||||
incad word
|
||||
nokeep ld2 INWORD,state ; Always: set state to INWORD
|
||||
jmp loop ; and get the next character.
|
||||
;
|
||||
; CASE INWORD
|
||||
;
|
||||
|
@ -294,7 +306,7 @@ case_inword if2 ch,eq,#000,endword
|
|||
incad buf
|
||||
and #$FF
|
||||
if2 @a,eq,#13,word2
|
||||
bra putword
|
||||
jmp putword
|
||||
word2 jmp loop
|
||||
endword dec buf
|
||||
finiword lda #0
|
||||
|
@ -334,6 +346,8 @@ errstr2 dc c"gsh: Missing ending '.",h'0d00'
|
|||
|
||||
command START
|
||||
|
||||
using vardata
|
||||
|
||||
pipefds equ 1
|
||||
errappend equ pipefds+4
|
||||
errfile equ errappend+2
|
||||
|
@ -473,7 +487,9 @@ chkchar if2 @a,eq,#' ',qneeded
|
|||
beq appword Done if null character.
|
||||
bra chkchar
|
||||
|
||||
qneeded inc needq Quotes needed.
|
||||
qneeded lda varkeepquote If env var KEEPQUOTE is set,
|
||||
bne appword required quotes are already in place.
|
||||
inc needq Otherwise, quotes are needed.
|
||||
|
||||
;
|
||||
; Append word to command line (optionally, with quotes)
|
||||
|
@ -494,7 +510,7 @@ nospace lda needq If special char is in parameter,
|
|||
beq noquote
|
||||
lda [word]
|
||||
and #$FF
|
||||
cmp #'"' and it doesn't start with '"',
|
||||
cmp #'"' and param doesn't start with '"',
|
||||
bne doquote
|
||||
stz needq
|
||||
bra noquote
|
||||
|
@ -1199,6 +1215,7 @@ mutex key
|
|||
**************************************************************************
|
||||
|
||||
execute START
|
||||
using vardata
|
||||
|
||||
exebuf equ 1
|
||||
pipesem equ exebuf+4
|
||||
|
@ -1322,7 +1339,6 @@ found_end anop
|
|||
sta end_char Save the ending character.
|
||||
|
||||
tya Get number of bytes in command.
|
||||
jeq goback If none, just skip it.
|
||||
|
||||
clc Add command length to
|
||||
adc cmdstrt starting address to
|
||||
|
@ -1331,6 +1347,9 @@ found_end anop
|
|||
adc cmdstrt+2
|
||||
sta cmdend+2
|
||||
|
||||
cpy #0 If number of bytes in command
|
||||
jeq chk_cmd = 0, just skip it.
|
||||
|
||||
lda end_char Get the termination character.
|
||||
beq expand If it's not a null byte,
|
||||
lda #0
|
||||
|
@ -1402,15 +1421,14 @@ expalias ldx ptr_glob+2
|
|||
ora exebuf+2
|
||||
jeq errexit
|
||||
|
||||
* >> Temporary debug code: echo expanded command if echo is set.
|
||||
using vardata
|
||||
ldy varecho
|
||||
beq noecho
|
||||
; echo expanded command if echox is set.
|
||||
ldy varechox
|
||||
beq noechox
|
||||
ldx exebuf+2
|
||||
lda exebuf
|
||||
jsr puts
|
||||
jsr newline
|
||||
noecho anop
|
||||
noechox anop
|
||||
|
||||
* command subroutine (4:waitpid,2:inpipe,2:jobflag,2:inpipe2,
|
||||
* 4:pipesem,4:stream,4:awaitstatus)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: edit.asm,v 1.11 1999/01/14 17:44:24 tribby Exp $
|
||||
* $Id: edit.asm,v 1.12 1999/11/30 17:53:27 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
|
@ -96,23 +96,39 @@ GetCmdLine START
|
|||
stz currenthist
|
||||
stz currenthist+2
|
||||
|
||||
;
|
||||
; Get current state of tty
|
||||
;
|
||||
ioctl (#1,#TIOCGETP,#oldsgtty)
|
||||
ioctl (#1,#TIOCGETK,#oldttyk)
|
||||
ioctl (#1,#TIOCGLTC,#oldltc)
|
||||
|
||||
;
|
||||
; Set tty to return on character-by-character mode (CBREAK) and
|
||||
; map CR into LF; output LF as CR-LF (CRMOD)
|
||||
;
|
||||
ioctl (#1,#TIOCGETP,#newsgtty)
|
||||
lda #CBREAK+CRMOD
|
||||
sta sg_flags
|
||||
ioctl (#1,#TIOCSETP,#newsgtty)
|
||||
|
||||
ioctl (#1,#TIOCGETK,#oldttyk)
|
||||
;
|
||||
; Set ttyk bit fields to OAMAP+OA2META+VT100ARROW
|
||||
;
|
||||
ioctl (#1,#TIOCSETK,#newttyk)
|
||||
|
||||
ioctl (#1,#TIOCGLTC,#oldltc)
|
||||
;
|
||||
; Set tty to disable "delayed stop process signal" special character
|
||||
; (default value of ^Y)
|
||||
;
|
||||
ioctl (#1,#TIOCGLTC,#newltc)
|
||||
short m
|
||||
lda #-1
|
||||
sta newltc+1
|
||||
sta t_dsuspc
|
||||
long m
|
||||
ioctl (#1,#TIOCSLTC,#newltc)
|
||||
|
||||
|
||||
cmdloop lda #keybindtab
|
||||
sta 0
|
||||
lda #^keybindtab
|
||||
|
@ -149,8 +165,8 @@ eof ldx cmdlen
|
|||
lda varignore
|
||||
bne findcmd
|
||||
reterr jsr cursoron
|
||||
ioctl (#1,#TIOCSETP,#oldsgtty)
|
||||
ioctl (#1,#TIOCSETK,#oldttyk)
|
||||
ioctl (#1,#TIOCSETP,#oldsgtty) ; Restore original
|
||||
ioctl (#1,#TIOCSETK,#oldttyk) ; tty settings.
|
||||
ioctl (#1,#TIOCSLTC,#oldltc)
|
||||
sec
|
||||
rts
|
||||
|
@ -302,8 +318,8 @@ fix0 inx
|
|||
beq retdone
|
||||
ph4 #cmdline
|
||||
jsl InsertHistory
|
||||
retdone ioctl (#1,#TIOCSETP,#oldsgtty)
|
||||
ioctl (#1,#TIOCSETK,#oldttyk)
|
||||
retdone ioctl (#1,#TIOCSETP,#oldsgtty) ; Restore original
|
||||
ioctl (#1,#TIOCSETK,#oldttyk) ; tty settings.
|
||||
ioctl (#1,#TIOCSLTC,#oldltc)
|
||||
clc
|
||||
rts
|
||||
|
@ -564,23 +580,44 @@ cmdoa6c ldy cmdloc
|
|||
jsr moveright
|
||||
bra cmdoa6c
|
||||
|
||||
oldsgtty dc i1'0'
|
||||
dc i1'0'
|
||||
dc i1'0'
|
||||
dc i1'0'
|
||||
dc i2'0'
|
||||
;
|
||||
; sgtty data structures for current values and new values:
|
||||
;
|
||||
oldsgtty dc i1'0' sg_ispeed: input baud rate
|
||||
dc i1'0' sg_ospeed: output baud rate
|
||||
dc i1'0' sg_erase: line-edit erase char
|
||||
dc i1'0' sg_kill: line-edit kill char
|
||||
dc i2'0' sg_flags: various state settings
|
||||
|
||||
newsgtty dc i1'0'
|
||||
dc i1'0'
|
||||
dc i1'0'
|
||||
dc i1'0'
|
||||
sg_flags dc i2'0'
|
||||
sg_flags dc i2'0' sg_flags set to CBREAK+CRMOD
|
||||
|
||||
|
||||
;
|
||||
; ttyk bit map for current value and new value:
|
||||
;
|
||||
oldttyk dc i2'0'
|
||||
newttyk dc i2'OAMAP+OA2META+VT100ARROW'
|
||||
|
||||
oldltc ds 6
|
||||
newltc ds 6
|
||||
;
|
||||
; ltchars data structures for current values and new values:
|
||||
;
|
||||
oldltc dc i1'0' t_suspc: stop process signal (^Z)
|
||||
dc i1'0' t_dsuspc: delayed stop process sig (^Y)
|
||||
dc i1'0' t_rprntc: reprint line (^R)
|
||||
dc i1'0' t_flushc: flush output (^O)
|
||||
dc i1'0' t_werasc: word erase (^W)
|
||||
dc i1'0' t_lnextc: literal next char (^V)
|
||||
|
||||
newltc dc i1'0'
|
||||
t_dsuspc dc i1'0'
|
||||
dc i1'0'
|
||||
dc i1'0'
|
||||
dc i1'0'
|
||||
dc i1'0'
|
||||
|
||||
END
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Resources for version and comment
|
||||
*
|
||||
* $Id: gsh.rez,v 1.12 1999/02/08 17:26:50 tribby Exp $
|
||||
* $Id: gsh.rez,v 1.13 1999/11/30 17:53:27 tribby Exp $
|
||||
*/
|
||||
|
||||
#define PROG "gsh"
|
||||
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
resource rVersion (1, purgeable3) {
|
||||
{ 2, 0, 0, /* Version 2.0.0 */
|
||||
development, /* development|alpha|beta|final|release */
|
||||
10 }, /* non-final release number */
|
||||
alpha, /* development|alpha|beta|final|release */
|
||||
1 }, /* non-final release number */
|
||||
verUS, /* Country */
|
||||
PROG, /* Program name */
|
||||
DESC
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Jawaid Bazyar
|
||||
* Tim Meekins
|
||||
*
|
||||
* $Id: shell.asm,v 1.10 1999/02/08 17:26:51 tribby Exp $
|
||||
* $Id: shell.asm,v 1.11 1999/11/30 17:53:27 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
|
@ -35,6 +35,8 @@
|
|||
*
|
||||
* signal18 subroutine (4:fubar)
|
||||
*
|
||||
* signal21 subroutine (4:fubar)
|
||||
*
|
||||
**************************************************************************
|
||||
|
||||
mcopy /obj/gno/bin/gsh/shell.mac
|
||||
|
@ -47,6 +49,7 @@ dummyshell start ; ends up in .root
|
|||
SIGINT gequ 2
|
||||
SIGTSTP gequ 18
|
||||
SIGCHLD gequ 20
|
||||
SIGTTIN gequ 21
|
||||
|
||||
cmdbuflen gequ 1024
|
||||
|
||||
|
@ -109,6 +112,7 @@ fastskip1 anop
|
|||
signal (#SIGINT,#signal2)
|
||||
signal (#SIGTSTP,#signal18)
|
||||
signal (#SIGCHLD,#pchild)
|
||||
signal (#SIGTTIN,#signal21)
|
||||
;
|
||||
; Set entry point for users calling system
|
||||
;
|
||||
|
@ -636,3 +640,31 @@ signal18 START
|
|||
msg dc c'^Z',h'0d0a00'
|
||||
|
||||
END
|
||||
|
||||
;=========================================================================
|
||||
;
|
||||
; SIGTTIN handler
|
||||
;
|
||||
;=========================================================================
|
||||
|
||||
;
|
||||
; Work-around for kernel problem: if background read error signal
|
||||
; is received, gsh will hang forever. Instead, quit.
|
||||
;
|
||||
|
||||
signal21 START
|
||||
|
||||
using global
|
||||
|
||||
subroutine (4:fubar),0
|
||||
|
||||
WriteCString #bg_msg Print message.
|
||||
|
||||
Quit QuitParm
|
||||
|
||||
QuitParm dc i'0'
|
||||
; return
|
||||
|
||||
bg_msg dc c'gsh: SIGTTIN received!!',h'0d0a00'
|
||||
|
||||
END
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Tim Meekins
|
||||
* Derek Taubert
|
||||
*
|
||||
* $Id: shellvar.asm,v 1.8 1999/02/08 17:26:51 tribby Exp $
|
||||
* $Id: shellvar.asm,v 1.9 1999/11/30 17:53:27 tribby Exp $
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
|
@ -696,9 +696,27 @@ up9 anop
|
|||
pei (var)
|
||||
ph4 #oldpmodename
|
||||
jsr cmpdcstr
|
||||
bne done
|
||||
bne up10
|
||||
lda flag
|
||||
sta varoldpmode
|
||||
jmp done
|
||||
|
||||
up10 pei (var+2)
|
||||
pei (var)
|
||||
ph4 #varechoxname
|
||||
jsr cmpdcstr
|
||||
bne up11
|
||||
lda flag
|
||||
sta varechox
|
||||
jmp done
|
||||
|
||||
up11 pei (var+2)
|
||||
pei (var)
|
||||
ph4 #keepquotename
|
||||
jsr cmpdcstr
|
||||
bne done
|
||||
lda flag
|
||||
sta varkeepquote
|
||||
|
||||
done return
|
||||
|
||||
|
@ -800,6 +818,8 @@ pushdsilname dc c'pushdsilent',h'00'
|
|||
termname dc c'term',h'00'
|
||||
ignorename dc c'ignoreeof',h'00'
|
||||
oldpmodename dc c'oldpathmode',h'00'
|
||||
varechoxname dc c'echox',h'00'
|
||||
keepquotename dc c'keepquote',h'00'
|
||||
|
||||
; Table of flag values (must be in same order as string addresses)
|
||||
evvaltbl anop
|
||||
|
@ -811,6 +831,8 @@ varnobeep dc i2'0'
|
|||
varpushdsil dc i2'0'
|
||||
varignore dc i2'0'
|
||||
varoldpmode dc i2'0'
|
||||
varechox dc i2'0'
|
||||
varkeepquote dc i2'0'
|
||||
|
||||
evvaltblsz dc i2'evvaltblsz-evvaltbl' # bytes in table
|
||||
|
||||
|
|
Loading…
Reference in New Issue