aboutsummaryrefslogtreecommitdiff
path: root/bfc.sh
blob: 4bc87c10bba6994192f0611981656156826c6da8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env sh

set -e

BFC="./build/bfc"
SRC="$1"

if [ -z "$SRC" ]; then
  echo "usage: $0 <file.bf>" >&2
  exit 1
fi

# silently build compiler if missing
if [ ! -f "$BFC" ]; then
  make -s || {
    echo "build failed" >&2
    exit 1
  }
fi

# compile pipeline
OUT=$(cat "$SRC" | "$BFC")

echo "$OUT" | gcc -o ./bf.out -x c -