dansanderson / picotool

Tools and Python libraries for manipulating Pico-8 game files. http://www.lexaloffle.com/pico-8.php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

non 0 status on error

TeddyDD opened this issue · comments

p8tool should exit with non-zero status when error occurs while processing a cart.

Example:
10521 p8
p8tool stats returns

/home/teddy/.lexaloffle/pico-8/bbs/1/10521.p8.png: Expected end at line 474 char 31
/home/teddy/.lexaloffle/pico-8/bbs/1/10521.p8.png: could not load cart

on this cart but exit status is 0
This makes using p8tool in shell scripts quiet hard.

I'm having the same problem. I created a p8 file on a Windows machine, committed and pushed to github, pulled on a Mac, now getting this error. Plus the cart won't even load inside Pico-8. I've tried removing anything that seemed like it could be a weird character, resaved the file with a bunch of different encodings, replaced whitespace, etc. Nothing seems to be working.

This is specific to the stats command and is meant to accommodate the case where stats is used on multiple carts at once. I couldn't find prior art on status codes for partial successes and I didn't want stats to bail on a large list of carts if some of them could not be loaded. I'll add a special case where stats will return a status of 1 if there is only one cart requested and it could not be loaded. I welcome suggestions on better ways to handle the multi-cart invocation.

I'm also not consistent in the multi-cart invocations. writep8, luamin, and luafmt currently return 1 on any failure but still process all files. In an upcoming change, stats, listlua and others will return 1 only if there's only one file requested and it's in error. Someday I'll put more thought into this. :)

I found a few other places that need better error handling for these carts as well. I'll try to tighten them up.

As for why it's failing to parse in some cases, I see a few cases where if the cart's Lua region has weird characters in it that Pico-8 is OK with but picotool is not. I'll stomp these out one at a time and see how many carts it fixes.

The error in the cart attached to this issue is "if (cond) do\n ...". As per #6 this isn't actually Lua ("if (cond) then\n ..." is correct) but is allowed by Pico-8 due to a quirk in its "short-if" feature.

Resolving this issue for now. Thanks for the report!