3 # Copyright (C) 1998 Richard Braakman
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, you can find it on the World Wide
17 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
18 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21 # Functions are defined here to read a shell script and return it as
24 # We do NOT do history expansion, because it's normally turned off in
29 # <<- << >> && || <> >| >& ;; (( <& >& ( ) < > ; & | -
42 foreach (split(/\n/, $_[0])) {
43 if ($state == 0) { # base
44 s/^\s+//; # skip leading whitespace
46 # skip blank lines, skip comments till end of line
53 elsif (s/^( <<- | << | >> | <> | >\| | >& )//x) {
59 elsif (s/^( && | \|\| )//x) {
67 $state = 1; # case pattern
72 elsif ($reserved_ok and s/^ \(\( //x) {
74 $state = 2; # dparen arithmetic
79 elsif (s/^( <& | >& )//x) {
81 # hack <& - and >& - cases.
82 # No comments or newlines can appear between the <& and -.
90 elsif (m/^( <\( | >\( )/x) {
96 elsif (s/^( < | > )//x) {
102 elsif (s/^([();&|])//) {