File: shell-stripper

package info (click to toggle)
shoop 0.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 328 kB
  • ctags: 41
  • sloc: sh: 1,138; makefile: 209; perl: 44
file content (54 lines) | stat: -rwxr-xr-x 1,133 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
#
# This is a perl script that can strip uneeded characters from a
# shell script, so that certain shells(bash!) can run it faster.
#
# Copyright 2000 by Adam Heath <doogie@debian.org>
# Licensed under the LGPL
#

$first = 1;
while (<>) {

	#
	# Remove continuation characters.  This is done first
	# incase the script magic below is a continued line.
	#
	if(/\\$/) {
		chop;s/\\$//;
		$_ .= <>;
		redo if not eof;
	};

	#
	# Don't throw away the script magic identifier.
	#
	if(!(defined $first && /^#!/)) {
		#
		# Strip leading whitespace.
		#
		s/[ \t]*//;

		#
		# Skip blank and comment lines.
		#
		next if(/^(#.*|)$/);
	}

	#
	# If a line ends with ;, then combine it with the next
	# line, as the new line character is extraneous.
	#
	chop if(/\;[ \t]*$/);

	print if(/^#!/);
	if(defined $first) {
		print "# This script has been preprocessed prior to installation\n";
		print "# It has had comments, blank lines, and leading spaces\n";
		print "# removed, and \\-style lines combined.  This was done so\n";
		print "# that it could run quicker under some shells.\n"
	}
	print if(! /^#!/);
	undef $first;

}