strip-script.sh 1.7 KB

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