chiark / gitweb /
Move AFE-related programs into a separate directory.
[bin.git] / format
1 #!/bin/bash
2
3 # Parameterizes a document.
4 # Input arguments Param1 Value1 Param2 Value2 ... will replace
5 # $Param1$ with Value1, $Param2$ with Value2, and so on.
6
7 # Arguments with spaces in must be quoted.
8
9 function getargs ()
10 {
11         while [ $# != 0 -a $# != 1 ]; do
12                 SUBST=${2//\'/\'\\\'\'};
13                 SUBST=${SUBST//\//\\\/};
14                 echo -n -;
15                 echo -n e \'s/\\\$$1\\\$/$SUBST/g\'\ ;
16                 shift 2;
17         done
18         echo -n -;
19         echo -n e \'s/\\\$\%/\$/g\' -e \'s/\\\$\\\$/\$/g\'\ ;
20         echo -n $1;
21 }
22
23 if [ "$1" == "-v" ]; then
24         shift;
25         bash --norc -vc "sed `getargs \"$@\"`";
26 else
27         bash --norc -c "sed `getargs \"$@\"`";
28 fi
29