#! /usr/bin/env bash # Change VC10 project file for another example. # # -n # -f = matched with trailing . (must have ext); multiple # -x # trap 'exit 1' ERR function error () { echo "$*" 1>&2 } function uuid () { uuidgen | sed -e 's#\(.*\)#\U\1#' } new= xsd= fop= while [ $# -gt 0 ]; do case $1 in -n) shift new=$1 shift ;; -f) shift o=`echo $1 | sed -e 's#\(.*\)=\(.*\)#\1#'` n=`echo $1 | sed -e 's#\(.*\)=\(.*\)#\2#'` echo "file change: $o.* -> $n.*" fop="$fop -e s/$o\./$n./g" shift ;; -x) shift xsd=$1 shift ;; -*) error "unknown option: $1" exit 1 ;; *) break ;; esac done if [ "$new" = "" ]; then error '-n expected' exit 1 fi if [ "$xsd" = "" ]; then error '-x expected' exit 1 fi if [ "$1" = "" ]; then error 'input file expected' exit 1 fi old=`echo "$1" | sed -e 's/\(.*\)-10.0.vcxproj/\1/'` ext=`echo "$1" | sed -e 's/.*-\(10.0.vcxproj\)/\1/'` echo "old name : $old" echo "new name : $new" echo "new xsd cmd: $xsd" sed \ -e "s#$old#$new#" \ -e "s#{.*}#{`uuid`}#" \ -e "s#$old#$new#" \ -e "s#xsd.exe .* \([^ ][^ ]*\)#xsd.exe $xsd \1#" \ $fop \ $1 >$new-$ext todos $new-$ext sed \ -e "s#.*#uuidgen | sed -e 's%\\\\(.*\\\\)% {\\\\U\\\\1\\\\E}%'#e" \ $fop \ $1.filters >$new-$ext.filters todos $new-$ext.filters