From 78a71b3bd3ae72f3cc2c121e917ed625a7ec09f1 Mon Sep 17 00:00:00 2001 From: RandumKiwi Date: Wed, 6 Mar 2013 11:43:12 +0000 Subject: [PATCH] Smarter preserve option for stripping... git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7319 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- config/convert_mapconfig.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/config/convert_mapconfig.sh b/config/convert_mapconfig.sh index 78d2ab2f..feb830af 100644 --- a/config/convert_mapconfig.sh +++ b/config/convert_mapconfig.sh @@ -60,19 +60,25 @@ for file in $*; do if [ "$1" = "-s" ] || [ "$1" = "--strip" ] || [ "$1" = "-os" ] || [ "$1" = "-sp" ] || [ "$1" = "-osp" ]; then echo "Now stripping "$file" of comments, invalid commands, leading/trailing spaces/tabs and blank lines..." # 1) Remove comments. - # 2) Show ONLY lines starting with: loadnotexture loadsky mapmodelreset mapmodel texturereset texture fog fogcolour mapsoundreset mapsound watercolour shadowyaw - # 3) Remove leading/trailing spaces/tabs. + # 2) Remove leading/trailing spaces/tabs. + # 3) Show ONLY lines starting with: loadnotexture loadsky mapmodelreset mapmodel texturereset texture fog fogcolour mapsoundreset mapsound watercolour shadowyaw # 4) Remove blank lines. - # 5) IF ENABLED, preserve comments made before the "mapmodelreset" command. + # 5) IF ENABLED: Preserve comments made before the "mapmodelreset" command. sed -i 's/\/\/..*//g' $file - sed -ni '/^loadnotexture\|^loadsky\|^mapmodelreset\|^mapmodel\|^texturereset\|^texture\|^fog\|^fogcolour\|^mapsoundreset\|^mapsound\|^watercolour\|^shadowyaw/p' $file sed -i 's/^[ \t]*//;s/[ \t]*$//' $file + sed -ni '/^loadnotexture\|^loadsky\|^mapmodelreset\|^mapmodel\|^texturereset\|^texture\|^fog\|^fogcolour\|^mapsoundreset\|^mapsound\|^watercolour\|^shadowyaw/p' $file sed -i '/^$/d' $file if [ "$1" = "-sp" ] || [ "$1" = "-osp" ]; then + # Create a working file... cp $file $file.tmp + # Grab data before the "mapmodelreset" command (excluding that line) from the original file... sed '/^mapmodelreset/q' $file.BAK | sed '$d' > $file - cat $file.tmp >> $file && rm -f $file.tmp + # Remove leading/trailing spaces/tabs from it... sed -i 's/^[ \t]*//;s/[ \t]*$//' $file + # Keep only comments/new-lines from it... + sed -ni '/^\/\/\|^$/p' $file + # Paste/remove working file into normal file... + cat $file.tmp >> $file && rm -f $file.tmp fi fi if [ "$1" = "-os" ] || [ "$1" = "-osp" ]; then