source: freewrt/scripts/strip-script.sh@ 655dec8

Last change on this file since 655dec8 was 1dc98f0, checked in by Thorsten Glaser <tg@…>, 19 years ago

this is a script to strip all

  • leading and trailing whitespace
  • hash-mark comments except shebang lines

from e.g. shell scripts and config files

derived from MirOS BSD Lstripcom() function

git-svn-id: svn://www.freewrt.org/trunk/freewrt@2154 afb5a338-a214-0410-bd46-81f09a774fd1

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