ksherlock / mpw

Macintosh Programmer's Workshop (mpw) compatibility layer
238 stars 21 forks source link

Add error message when loader can't load command #55

Closed ryandesign closed 1 year ago

ryandesign commented 1 year ago

I was trying to use the CodeWarrior MWC68K and MWCPPC compilers with the mpw emulator and I got no error message and only exit code 78, which was confusing:

% mpw MWC68K; echo $?
78
% mpw MWCPPC; echo $?
78
%

It took me some time to realize that the method I had used to transfer the MWC68K and MWCPPC tools from my Power Mac had not preserved the resource fork which of course made the tools unusable.

Exit code 78 is EX_CONFIG and there are several places in the code that use this exit code but most of them first print error messages and are about actual configuration errors, like specifying non-numbers for parameters that need to be numbers.

In this case, a different exit code might be clearer. I changed it to EX_SOFTWARE; I'm not sure if that's correct but it seems more accurate than EX_CONFIG and you've used elsewhere in the code already. I also added an error message based on the error code returned from the loader. Now my situation gives this somewhat more helpful output:

% mpw MWC68K; echo $?
Unable to load command /Users/rschmidt/mpw/MetroWerks/Tools/MWC68K: Logical end-of-file reached during read operation
70
% mpw MWCPPC; echo $?
Unable to load command /Users/rschmidt/mpw/MetroWerks/Tools/MWCPPC: Logical end-of-file reached during read operation
70
%
ksherlock commented 1 year ago

thanks