From d474af1565119891a77ab17dfef7ef70932c5102 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Fri, 27 Sep 2002 20:26:35 +0000 Subject: [PATCH] Added for CRLF translation. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@88 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/fixcrlf | 4 ++++ sc2/subst | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 sc2/fixcrlf create mode 100755 sc2/subst diff --git a/sc2/fixcrlf b/sc2/fixcrlf new file mode 100755 index 000000000..457d0507c --- /dev/null +++ b/sc2/fixcrlf @@ -0,0 +1,4 @@ +#!/bin/sh +find src -type f -print0 | xargs -0 ./subst 's/ +$//g' + diff --git a/sc2/subst b/sc2/subst new file mode 100755 index 000000000..88fbf9c1f --- /dev/null +++ b/sc2/subst @@ -0,0 +1,45 @@ +#!/usr/bin/bash +# Substitute a string in many files. By Serge van den Boom, 20020826 + +if [ $# -eq 0 ]; then + { + echo "subst: substitute a string in a lot of files." + echo "By Serge van den Boom, 20020826" + echo "Usage: subst [...]" + echo -n "'pattern' should be a pattern in the form used by sed, " + echo " like 's/old/new/g'." + } 1>&2 + exit 1 +fi + +PAT="$1" +SEP="${PAT:1:1}" +GREPPAT="${PAT:2}" +eval GREPPAT='${GREPPAT%%'$SEP'*}' +shift +while [ "$#" -gt "0" ]; do + FILE="$1" + echo -n "$FILE: " + grep -q "$GREPPAT" < "$FILE" + EXITVAL=$? + case $EXITVAL in + 0) # Match found + ;; + 1) # No match found + echo "Nothing to do." + shift + continue + ;; + *) + echo "ERROR" + echo "Error: grep returned exit value ${EXITVAL}. Aborted." 1>&2 + exit 1 + esac + TEMPFILE="${FILE}.patchtree.$$.tmp" + mv -- "$FILE" "$TEMPFILE" + sed -e "$PAT" < "$TEMPFILE" > "$FILE" + rm -- "$TEMPFILE" + echo "Done." + shift +done +