mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-17 06:18:06 +11:00
shell: allow cmds to be shorter than 4 chars
This commit is contained in:
parent
70a42e8c4d
commit
77d805ea0f
@ -19,30 +19,18 @@
|
|||||||
.equ PGM_RAMEND PGM_HANDLE+FS_HANDLE_SIZE
|
.equ PGM_RAMEND PGM_HANDLE+FS_HANDLE_SIZE
|
||||||
|
|
||||||
; Routine suitable to plug into SHELL_CMDHOOK. HL points to the full cmdline.
|
; Routine suitable to plug into SHELL_CMDHOOK. HL points to the full cmdline.
|
||||||
; We can mutate it because the shell doesn't do anything with it afterwards.
|
; which has been processed to replace the first ' ' with a null char.
|
||||||
pgmShellHook:
|
pgmShellHook:
|
||||||
call fsIsOn
|
call fsIsOn
|
||||||
jr nz, .noFile
|
jr nz, .noFile
|
||||||
; first first space and replace it with zero so that we have something
|
; (HL) is suitable for a direct fsFindFN call
|
||||||
; suitable for fsFindFN.
|
|
||||||
push hl ; remember beginning
|
|
||||||
ld a, ' '
|
|
||||||
call findchar
|
|
||||||
jr nz, .noarg ; if we have no arg, we want DE to point to the
|
|
||||||
; null char. Also, we have no replacement to
|
|
||||||
; make
|
|
||||||
; replace space with nullchar
|
|
||||||
xor a
|
|
||||||
ld (hl), a
|
|
||||||
inc hl ; make HL point to the beginning of args
|
|
||||||
.noarg:
|
|
||||||
ex de, hl ; DE now points to the beginning of args or to \0 if
|
|
||||||
; no args
|
|
||||||
pop hl ; HL points to cmdname, properly null-terminated
|
|
||||||
call fsFindFN
|
call fsFindFN
|
||||||
jr nz, .noFile
|
jr nz, .noFile
|
||||||
; We have a file! Load it and run it.
|
; We have a file! Advance HL to args
|
||||||
ex de, hl ; but first, make HL point to unparsed args.
|
xor a
|
||||||
|
call findchar
|
||||||
|
inc hl ; beginning of args
|
||||||
|
; Alright, ready to run!
|
||||||
jp pgmRun
|
jp pgmRun
|
||||||
.noFile:
|
.noFile:
|
||||||
ld a, SHELL_ERR_IO_ERROR
|
ld a, SHELL_ERR_IO_ERROR
|
||||||
|
@ -100,9 +100,23 @@ shellParse:
|
|||||||
push hl
|
push hl
|
||||||
push ix
|
push ix
|
||||||
|
|
||||||
|
; Before looking for a suitable command, let's make the cmd line more
|
||||||
|
; usable by replacing the first ' ' with a null char. This way, cmp is
|
||||||
|
; easy to make.
|
||||||
|
push hl ; --> lvl 1
|
||||||
|
ld a, ' '
|
||||||
|
call findchar
|
||||||
|
jr z, .hasArgs
|
||||||
|
; no arg, (HL) is zero to facilitate processing later, add a second
|
||||||
|
; null next to that one to indicate unambiguously that we have no args.
|
||||||
|
inc hl
|
||||||
|
.hasArgs:
|
||||||
|
xor a
|
||||||
|
ld (hl), a
|
||||||
|
pop hl ; <-- lvl 1, beginning of cmd
|
||||||
|
|
||||||
ld de, shellCmdTbl
|
ld de, shellCmdTbl
|
||||||
ld a, SHELL_CMD_COUNT
|
ld b, SHELL_CMD_COUNT
|
||||||
ld b, a
|
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
push de ; we need to keep that table entry around...
|
push de ; we need to keep that table entry around...
|
||||||
@ -131,13 +145,9 @@ shellParse:
|
|||||||
call intoDE ; Jump from the table entry to the cmd addr.
|
call intoDE ; Jump from the table entry to the cmd addr.
|
||||||
|
|
||||||
; advance the HL pointer to the beginning of the args.
|
; advance the HL pointer to the beginning of the args.
|
||||||
ld a, ' '
|
xor a
|
||||||
call findchar
|
call findchar
|
||||||
or a ; end of string? don't increase HL
|
inc hl ; beginning of args
|
||||||
jr z, .noargs
|
|
||||||
inc hl ; char after space
|
|
||||||
|
|
||||||
.noargs:
|
|
||||||
; Now, let's have DE point to the argspecs
|
; Now, let's have DE point to the argspecs
|
||||||
ld a, 4
|
ld a, 4
|
||||||
call addDE
|
call addDE
|
||||||
|
@ -123,7 +123,7 @@ f1PutC:
|
|||||||
jp fsPutC
|
jp fsPutC
|
||||||
|
|
||||||
edCmd:
|
edCmd:
|
||||||
.db "eded", 0b1001, 0, 0
|
.db "ed", 0, 0, 0b1001, 0, 0
|
||||||
push hl \ pop ix
|
push hl \ pop ix
|
||||||
ld l, (ix)
|
ld l, (ix)
|
||||||
ld h, (ix+1)
|
ld h, (ix+1)
|
||||||
|
Loading…
Reference in New Issue
Block a user