fiano
fiano copied to clipboard
Consider using Forth rather than the pipeline
Right now, utk2 uses a pipeline like the following:
utk winterfell.rom \
remove 12345678-9abc-def0-1234-567890abcdef \
remove 23830293-3029-3823-0922-328328330939 \
replace_pe32 Shell linux.efi \
save winterfell2.rom
We might be able to have more flexibility with a forth-like interface:
utk winterfell.rom \
find 12345678-9abc-def0-1234-567890abcdef remove \
find 23830293-3029-3823-0922-328328330939 remove \
find Shell replace_pe32 linux.efi \
save winterfell2.rom
This suggestion comes from @rminnich
this is a prefix example and maybe that's nicer anyway. I.e. forth would be utk w.rom 12345678-9abc-def0-1234-567890abcdef find remove
and your prefix notation may be nicer
It begs the question: what if the find fails?
So the design of the operators needs to be done carefully.
one could do this GUID find pushes (guid, true) or (false) if remove then if consumes the top of stack and, if true, runs remove, which consumes the GUID at TOS
the full program
utk
w.rom romread
12345678-9abc-def0-1234-567890abcdef find if remove then
12345678-9abc-def0-1234-567890abcdef find if remove then
;;; push linux.efi and then make a replace or insert
linux.efi load
;;; linux.efi is now TOS
;;; if the shell is there replace with TOS else install TOS
Shell find if replace else install then
winterfell2.rom save \
note that w.rom now comes with an operator. There's no implicit operator that comes from being first in the argv. This is nice as you can do other stuff, THEN open the rom file. This allows in future for opening more than one rom file.
TBH, at first, it felt awkward and after a minute I started to like it. There's no implicit action based on positional parameters, just a simple textual program in argv.
utk w.rom open
12345678-9abc-def0-1234-567890abcdef find if remove then
12345678-9abc-def0-1234-567890abcdef find if remove then
linux.efi load
Shell find if replace else install then
winterfell2.rom save
note that you can even do this:
utk w.rom open
do 12345678-9abc-def0-1234-567890abcdef find if remove then loop ;
linux.efi load Shell find if replace else install then
w.rom save
i.e. if you have an undefined number of GUIDS of same name, looping to remove them is simple. I did not remember any of this, I just went to https://www.forth.com/starting-forth/0-starting-forth/ and took it from there.
I don't want to tell people to go learn forth just to use the command line interface of our program..
Ok I'm convinced. It would make certain things easier, like diffing two bioses.