Damien Miller | ab1c12a | 2002-12-05 20:59:33 +1100 | [diff] [blame^] | 1 | #!/bin/sh |
Damien Miller | c0d7390 | 1999-12-27 09:23:58 +1100 | [diff] [blame] | 2 | # |
| 3 | # fixpaths - substitute makefile variables into text files |
Damien Miller | ab1c12a | 2002-12-05 20:59:33 +1100 | [diff] [blame^] | 4 | # Usage: fixpaths -Dsomething=somethingelse ... |
Damien Miller | c0d7390 | 1999-12-27 09:23:58 +1100 | [diff] [blame] | 5 | |
Damien Miller | ab1c12a | 2002-12-05 20:59:33 +1100 | [diff] [blame^] | 6 | die() { |
| 7 | echo $* |
| 8 | exit -1 |
Damien Miller | c0d7390 | 1999-12-27 09:23:58 +1100 | [diff] [blame] | 9 | } |
| 10 | |
Damien Miller | ab1c12a | 2002-12-05 20:59:33 +1100 | [diff] [blame^] | 11 | test -n "`echo $1|grep -- -D`" || \ |
| 12 | die $0: nothing to do - no substitutions listed! |
Damien Miller | c0d7390 | 1999-12-27 09:23:58 +1100 | [diff] [blame] | 13 | |
Damien Miller | ab1c12a | 2002-12-05 20:59:33 +1100 | [diff] [blame^] | 14 | test -n "`echo $1|grep -- '-D[^=]\+=[^ ]\+'`" || \ |
| 15 | die $0: error in command line arguments. |
Damien Miller | c0d7390 | 1999-12-27 09:23:58 +1100 | [diff] [blame] | 16 | |
Damien Miller | ab1c12a | 2002-12-05 20:59:33 +1100 | [diff] [blame^] | 17 | test -n "`echo $*|grep -- ' [^-]'`" || \ |
| 18 | die Usage: $0 '[-Dstring=replacement] [[infile] ...]' |
Damien Miller | c0d7390 | 1999-12-27 09:23:58 +1100 | [diff] [blame] | 19 | |
Damien Miller | ab1c12a | 2002-12-05 20:59:33 +1100 | [diff] [blame^] | 20 | sed `echo $*|sed -e 's/-D\([^=]\+\)=\([^ ]*\)/-e s=\1=\2=g/g'` |
| 21 | |
| 22 | exit 0 |