[Feature discussion] Calling system commands from rgbasm #930
Closed
Rangi42
started this conversation in
Discussions
Replies: 1 comment 2 replies
-
I already know @ISSOtm is not going to accept this. :P |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is a rough draft for a set of features which I would like to cover the most obvious use cases of the proposed #928, without needing potentially years of planning and prep work to make it usable. I also want to make as few changes as necessary, as opposed to inventing new ad-hoc features for slightly different use cases. (I.e. no adding built-in
COMPRESS
,RANDOM
,FILESIZE
,READURL
, etc functions.)Macros are already powerful enough to do conditional logic, building up state through multiple macro calls, etc; they just aren't efficient for things like compression algorithms, nor capable of accessing external data from the filesystem or network (unless you
INCLUDE
a file in rgbasm's own syntax, and have Makefile rules to create the file appropriately).System commands can take a stream of stdin input, and they give streams of stdout and stderr output, plus a numeric return code. These could all be handled by a single
SYSEXEC
directive, which sets the values of global__SYSOUT__
,__SYSERR__
, and__SYSRET__
symbols, and optionally takes a string for stdin:(I went with global variables for the out/err/ret values since allowing up to four parameters for specifying custom symbols could get awkward; it's easy to confuse the order if they're all comma-separated, and we don't typically have keywords like
SYSEXEC "cat" IN "hello" OUT outstring RET catcode
.)@ISSOtm You compared something like this unfavorable to LaTeX's
\write18
in #928. I don't think it would be a big deal in practice, since repos can already put evil commands in obscure input files for commands in their Makefile; but I do understand the concern. Apparently TeX Live and MiKTeX have a workaround for this: "restricted\write18
" where only whitelisted commands can execute. So you would have to runrgbasm --allow-sysexec false,cat,textcomp foo.asm
for the above to work. (It's a lot easier for the user to audit just the Makefile for any--allow-sysexec
s than all the .asm files.)Beta Was this translation helpful? Give feedback.
All reactions