Skip to content

Instantly share code, notes, and snippets.

@mbrock
Created November 23, 2025 23:09
Show Gist options
  • Select an option

  • Save mbrock/0f5add44a1e20d42bad4b8c0c2137830 to your computer and use it in GitHub Desktop.

Select an option

Save mbrock/0f5add44a1e20d42bad4b8c0c2137830 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
{ test -f "$1" && test "$2" = -o; } ||
{ echo Usage: $0 input.ni -o output.ulx; exit 1; }
cat /dev/null >"$3"; trap 'rm -f "$3"' ERR
w=$((65 - ${#1})) nifmt='{
print() if [[ $text ]]; then
re=" (source text, line \([0-9]*\))"
n=`echo "$text" | sed "s/.*$re.*/\1/"`
text=`echo "$text" | sed "s/$re//"`
case "$n" in *[^0-9]*) n="??"; esac
echo "$text" | fmt -w '$w' | sed "2,\$s/^/ /" |
sed "s/^/'$1':$n:1: error: /"; fi
while IFS= read -r line; do case "$line" in
" >--> "*) print; text="${line:7}";;
" "*) text+=" ${line:4}";;
*) print; text=; echo "$line";;
esac; done; print; }'
docker run --rm -t \
-v "`realpath $1`":/Story.inform/Source/story.ni:ro \
-v "`realpath $3`":"`realpath $3`":rw \
dbrock/i7 bash -ec "
uuidgen >/Story.inform/uuid.txt
set -o pipefail
ni --internal /usr/local/share/inform7/Internal \
--format=ulx --project /Story.inform 2>&1 >/dev/null |
{ grep -v ^++ || true; } | $nifmt || true
if ! output=\`inform6 -kE2wSDGx /Story.inform/Build/auto.inf \
-o \"`realpath $3`\"\`; then echo "$output"; exit 1; fi
"
#!/usr/bin/env bash
set -e -o pipefail
dir=`mktemp -d`
echo "$1" >$dir/source.ni
i7c $dir/source.ni -o $dir/output.ulx
{ printf %s\\n "${@:2}" q y; } |
dumb-glulxe $dir/output.ulx | tail -n +8 | head -n -2 | {
commands=(${@:2})
while read line; do
if [[ $line = ">"* ]]; then
echo ">${commands[0]}"
echo "${line:1}"
commands=(${commands[@]:1})
else
echo "$line"
fi
done
}
#!/usr/bin/env bash
set -e -o pipefail
dir=`mktemp -d`
echo "$1" >$dir/source.ni
i7c $dir/source.ni -o $dir/output.ulx
{ printf %s\\n "${@:2}" q y; } |
dumb-glulxe $dir/output.ulx | tail -n +8 | head -n -2 | {
commands=(${@:2})
while read line; do
if [[ $line = ">"* ]]; then
echo ">${commands[0]}"
echo "${line:1}"
commands=(${commands[@]:1})
else
echo "$line"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment