mpw-shell icon indicating copy to clipboard operation
mpw-shell copied to clipboard

How run a script with arguments?

Open uliwitness opened this issue 2 years ago • 6 comments

I'm trying to get this to run in my (non-MPW) makefile:

MakePPCCodeRsrc build/obj/$(EXECUTABLE).tmp -o $(EXECUTABLE) -append -rt xcmd=7000 -c 'RSED' -t 'rsrc' -rn $(EXECUTABLE)

Installed copied the Scripts folder from Apple's MPW to ~/mpw/Scripts/. Tried

~/mpw/bin/mpw-shell -c "MakePPCCodeRsrc build/obj/$(EXECUTABLE).tmp -o build/$(EXECUTABLE) -append -rt xcmd=7000 -c 'RSED' -t 'rsrc' -rn $(EXECUTABLE)"

And as long as I add {MPW}Scripts to $Commands that seems to run, but it then fails with

Exiting - PC = 0
make: *** [build/SelectionMode] Error 70

I tried adding -v before -c to get some additional information, but that doesn't seem to have any effect. Also tried :build:obj:$(EXECUTABLE).tmp as the path. I'm assuming something about the file paths is wrong, but no idea how to confirm that or what format this stuff should really be. Do I somehow need to tell mpw-shell about the current directory from zsh? Or should it just pick that up?

uliwitness avatar Oct 16 '22 14:10 uliwitness

Well, it looks like that's not actually supported yet (the above errors is from trying to run it as an executable with MPW which doesn't work). execute MakePPCCodeRsrc will run it as a script but that doesn't pass any of the parameters so it's not useful. I'll try to add script support.

ksherlock avatar Oct 16 '22 16:10 ksherlock

I'm curious, would adding this be complicated, or is it something I could do, like adding a command-line argument that calls through to a particular function?

uliwitness avatar Nov 01 '22 10:11 uliwitness

The main hangup is environment variable handling. I did some testing with MPW in Basilisk and it looks like with user scripts, they get their own copy of the local variables which are isolated from the main shell's variables (but scripts can also export them out). Currently, there's one big table of variables and some are flagged as exported so that would need to change. For the most part, it's probably not a big deal if local environment variables are shared but if a script calls another script, the argument variables (0, 1, 2, ...) will be clobbered.

ksherlock avatar Nov 01 '22 19:11 ksherlock

scripts should work now. You may need to mark them as text (SetFile -t TEXT file). The MakePPCCodeRsrc won't work yet because regular expressions aren't yet supported (they're in progress).

ksherlock avatar Nov 14 '22 04:11 ksherlock

I added regular expression support to evaluate ... but there are a couple other deficiencies that are preventing that script from running.

ksherlock avatar Nov 22 '22 22:11 ksherlock

Thanks for all the work you've put into this so far. If there's anything I can help with, let me know.

uliwitness avatar Feb 06 '24 20:02 uliwitness