Greetings fellow scripters.
I find myself editing multiple files, sometimes with the same bits of information. My bash script, a changelog, and a plist file (OS X). Once I realized this, I thought why not script part of this process (and so it begins). In any case, I've solved several of the tasks I've set forth for myself. My new update script will update version/revision numbers in all files, and add text to the top of my change log using a combination of bash, python, and now perl (I think I'm nerding out a bit). I know this is all overkill, I just wanted to see if I could do it.
So, with the command
./update.sh 1.8.8.8 "some text for a change log header" /some.plist
pVersion="$1"
pRevision=$(echo "$1" | awk -F. '{print $4}')
vHeader=$(echo $pVersion | sed -e 's/\.//g' -e 's/^/v/')
pChangeLog=$2
export PVERSION=$pVersion
export PREVISION=$pRevision
export PLISTPATH="$3"
python - <<END
import os
import plistlib
pVersion=os.environ['PVERSION']
pRevision=os.environ['PREVISION']
plistPath=os.environ['PLISTPATH']
Plist=plistlib.readPlist(plistPath)
Plist['ProductVersion'] = pVersion
Plist['Revision'] = pRevision
plistlib.writePlist(Plist, plistPath)
END
perl -spi -e "s/version=\"*.*.*.*\"/version=\"$pVersion\"/g" somescript.sh
What I'm stuck with is the next bit.
perl -spi -e "s/change\ log/change\ log\n#\t$pVersion\n#\t-$pChangeLog/g"
Well, maybe not stuck. It works fine. But, if I could somehow make this perl one-liner also wrap text at 80 columns and add a "#\t\t" at the start of each line (and make me a sandwich).... Is that just asking too much? Maybe I should cut down on the energy drinks.
---------- Post updated at 23:21 ---------- Previous update was at 23:20 ----------
These are the things I do when I'm bored.