audinowho / PMDODump

All content generation for PMDO. BEWARE SPOILERS.
MIT License
62 stars 13 forks source link

Devmode scripts for other platforms #307

Open issuebotaudinowho[bot] opened 1 year ago

issuebotaudinowho[bot] commented 1 year ago

Discord: shitpost_sunkern#0 <@292039958829727744>

dev.bat — only works on Windows.

Thing is, the file with similar contents would run fine, but needs a different extension and permissions to be recognized by the OS as a script.

Mac: dev.command, needs to be chmod +x'd Contents Mac:

dir=$(echo "$0" | rev | cut -d "/" -f 2- | rev)
cd "$dir"
./PMDO -dev

Linux: dev.sh, needs to be chmod +x'd Contents Linux: ./PMDO -dev (double check this one because I can't)

AntyMew commented 1 year ago

Linux has the same problem, and won't work with that oneliner. A more concise script would be this (probably works on macos too so we don't need separate files, please confirm):

#!/usr/bin/env bash

cd "$(dirname "$0")"
./PMDO -dev
Shitpost-Sunkern commented 1 year ago

The contents of that do work (wow, wish I knew about dirname earlier...), but a few caveats:

  1. Bash is not the default shell on macOS; the version bundled in is very old and should not be used. A more robust shebang might be #! /bin/sh to get whatever the default configured POSIX shell is. Mac will also automatically do this if no shebang is provided.
  2. Even with identical contents, macOS won't open .sh files in Terminal by default, so the filename still has to end in .command for Mac.