#!/bin/bash # Parameterizes a document. # Input arguments Param1 Value1 Param2 Value2 ... will replace # $Param1$ with Value1, $Param2$ with Value2, and so on. # Arguments with spaces in must be quoted. function getargs () { while [ $# != 0 -a $# != 1 ]; do SUBST=${2//\'/\'\\\'\'}; SUBST=${SUBST//\//\\\/}; echo -n -; echo -n e \'s/\\\$$1\\\$/$SUBST/g\'\ ; shift 2; done echo -n -; echo -n e \'s/\\\$\%/\$/g\' -e \'s/\\\$\\\$/\$/g\'\ ; echo -n $1; } if [ "$1" == "-v" ]; then shift; bash --norc -vc "sed `getargs \"$@\"`"; else bash --norc -c "sed `getargs \"$@\"`"; fi