Skip to content

Instantly share code, notes, and snippets.

@mprentice
Created August 10, 2012 21:11
Show Gist options
  • Save mprentice/3318015 to your computer and use it in GitHub Desktop.
Save mprentice/3318015 to your computer and use it in GitHub Desktop.
Fix license text from xsl:comment to !--
#!/bin/bash
# Replace erroneous <xsl:comment> license tags with xml <!--> comments
bak="$HOME/tmp/xslbak"
mkdir -p "$bak"
find /usr/local/tusk/tusk-4_0_0 -name '*.xsl' -print0 | while IFS='' read -r -d '' fold ; do
lic=`awk '/<xsl:comment>/,/<\\/xsl:comment>/' "$fold" | grep 'licenses/ecl1\.php'`
if [ "" != "$lic" ] ; then
fdir="${fold%/*}"
fdir="${fdir#/usr/local/tusk/tusk-4_0_0/}"
fn="${fold##*/}"
fnew="$bak/$fdir/$fn"
mkdir -p "$bak/$fdir"
cp "$fold" "$fnew"
cat > "$fold" <<EOF
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2012 Tufts University
Licensed under the Educational Community License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
EOF
awk '/<xsl:stylesheet/,/<\/xsl:stylesheet>/' "$fnew" >> "$fold"
fi
done
@charles-dyfis-net
Copy link

Change:

find /usr/local/tusk/tusk-4_0_0 -name '*.xsl' | while read -r f ; do

to

find /usr/local/tusk/tusk-4_0_0 -name '*.xsl' -print0 | while IFS='' read -r -d '' f ; do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment