fixpaths 572 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env sh
  2. #
  3. # fixpaths - substitute makefile variables into text files
  4. # Usage: fixpaths -Dsomething=somethingelse ...
  5. die()
  6. {
  7. printf '%s\n' "${*}"
  8. exit 1
  9. }
  10. test -n "$(printf '%s\n' "$1" | grep -- -D)" ||
  11. die $0: nothing to do - no substitutions listed!
  12. test -n "$(printf '%s\n' "$1" | grep -- '-D[^=]\+=[^ ]\+')" ||
  13. die $0: error in command line arguments.
  14. test -n "$(printf '%s\n' "${*}" | grep -- ' [^-]')" ||
  15. die Usage: $0 '[-Dstring=replacement] [[infile] ...]'
  16. sed $(printf '%\n' "${*}" | sed -e 's/-D\([^=]\+\)=\([^ ]*\)/-e s=\1=\2=g/g')
  17. exit 0