strip-script.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (c) 2007
  2. # Thorsten Glaser <tg@mirbsd.de>
  3. #
  4. # Provided that these terms and disclaimer and all copyright notices
  5. # are retained or reproduced in an accompanying document, permission
  6. # is granted to deal in this work without restriction, including un-
  7. # limited rights to use, publicly perform, distribute, sell, modify,
  8. # merge, give away, or sublicence.
  9. #
  10. # Advertising materials mentioning features or use of this work must
  11. # display the following acknowledgement:
  12. # This product includes material provided by Thorsten Glaser.
  13. # This acknowledgement does not need to be reprinted if this work is
  14. # linked into a bigger work whose licence does not allow such clause
  15. # and the author of this work is given due credit in the bigger work
  16. # or its accompanying documents, where such information is generally
  17. # kept, provided that said credits are retained.
  18. #
  19. # This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
  20. # the utmost extent permitted by applicable law, neither express nor
  21. # implied; without malicious intent or gross negligence. In no event
  22. # may a licensor, author or contributor be held liable for indirect,
  23. # direct, other damage, loss, or other issues arising in any way out
  24. # of dealing in the work, even if advised of the possibility of such
  25. # damage or existence of a defect, except proven that it results out
  26. # of said person's immediate fault when using the work as intended.
  27. # Shell script to strip down a shell script (filter).
  28. shopt -s extglob
  29. cat "$@" | while read -r _line; do
  30. set -o noglob
  31. [[ $_line = \#* && $_line != @(#!)* ]] && continue
  32. [[ -n $_line ]] && builtin printf '%s\n' "$_line"
  33. done
  34. exit 0