Log In  

I often use shell scripts to export and then upload my games to itch.io, and there's a small inconvenience that trips me up sometimes: If my game is too large, the export fails, but I have no way of detecting that from my shell script.

> pico8 game.p8 -export "-f froggypaint.html"
EXPORT: -f froggypaint.html
failed: code block too large

> echo $?
0

I would expect the status code (echo $?) to be 1 or some other failure code

(Hm, now that I've written this up I suppose I could work around this by reading stderr stdout and checking for the string "failed"...)

P#130092 2023-05-24 08:14

1

workaround: instead of pico8 game.p8 -export "-f froggypaint.html", use this instead:

function pico8_export() {
    P8FILE=${1?"need file"}
    EXPORT_ARGS=${2?"need export command"}
    TEMPFILE=$(mktemp)

    pico8 $P8FILE -export "$EXPORT_ARGS" | tee $TEMPFILE

    grep -q 'failed' $TEMPFILE
    # invert, so that grep match = failure exit code
    test $? -ne 0
}

pico8_export game.p8 "-f froggypaint.html"
P#130094 2023-05-24 08:59

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 10:16:13 | 0.005s | Q:7