cpp 633 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env bash
  2. # Source file.
  3. src="$(printf %q "$1")"
  4. shift
  5. # Output file the compiler expects.
  6. out="$(printf %q "$1")"
  7. shift
  8. # Create the file the compiler expects. It will check syntax.
  9. >"$out"
  10. cpp='cpp'
  11. opts=''
  12. while test "$#" != 0; do
  13. case "$1" in
  14. # Extract the option for the path to cpp.
  15. --cpp) shift; cpp="$(printf %q "$1")" ;;
  16. # Extract the option for our own output file.
  17. --out) shift; out="$(printf %q "$1")" ;;
  18. # Collect the rest of the command line.
  19. *) opts="$opts $(printf %q "$1")" ;;
  20. esac
  21. shift
  22. done
  23. # Execute the real preprocessor tool.
  24. eval "exec $cpp $src $out $opts"