summaryrefslogtreecommitdiffstats
path: root/bin/pbjexpand
blob: ed863011ed6cd39b45a7becf17d053f23e458af8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

cat $1 | while read op arg
do
    case "$op" in
    '!')
        expdepth=$((expdepth + 1))
        if [ "$expdepth" -gt 10 ]
        then
            echo 'pbjexpand: depth of 10 recursive macros, aborting.' 1>&2
            exit 1
        fi

        export expdepth
        $arg | $0 ;;
    *)
        echo $op $arg
    esac
done