Not sure why this was here, as it was _moved_ to Test...
[mono.git] / mcs / tools / gensources.sh
index 1cc696734927bcf23c3a62c004cc67a506e3bdca..7e71029d8bc8b374d441c9c1a58eed0affcaf8ea 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 includefile=$1
 excludefile=$2
@@ -26,12 +26,12 @@ readlist () {
        if [ ":${filelist##*:$onelist:*}:" = "::" ]  ; then return ; fi
        filelist=":$onelist$filelist"
 
-       onelistcontent=`cat $onelist | while read line ; do echo -n $line ; echo -n ":" ; done`
+       onelistcontent=`cat $onelist | sed "s=[ \t]*$==g" | while read line ; do echo -n $line ; echo -n ":" ; done`
 
        OFS="$IFS"
        IFS=":"
        for line in $onelistcontent ; do
-               line2=${line##\#include }
+               line2=${line##\#}
                if [ ":$line:" = ":$line2:" ] ; then
                        for linex in $excludelist ; do
                                if [ ":${line##$linex}:" = "::" ] ; then line="" ; fi
@@ -43,8 +43,11 @@ readlist () {
                                        list="$list$separator$line"
                                fi
                        fi
-               elif [ ":$line2:" != "::" ] ; then
-                       readlist "$line2"
+               else
+                       line3=${line2##include }
+                       if [ ":$line3:" != ":$line2:" -a ":$line3:" != "::" ] ; then
+                               readlist "$line3"
+                       fi
                fi
        done
        IFS="$OFS"