in reply to Re^11: No, "We" Don't Have to Do Anything
in thread No, "We" Don't Have to Do Anything
What's wrong with making perltidy actually robust enought that we know that nothing has changed.
If you mean either because the file hasn't changed since last it was tidied and perltidy doesn't need to do anything, or because there has been an error and it shouldn't overwrite your original file, then maybe this bit of shell script might prove helpful:
#!/bin/bash PERLTIDY=/usr/bin/perltidy PERLTIDYOPTIONS=' -l 123 ' TOUCH=/bin/touch DIFF=/usr/bin/diff CP=/bin/cp CPOPTIONS=' -v ' WC=/usr/bin/wc if [ $# -gt 0 ] then echo Command line: $0 $@ for file in $@ do if [ ! -e $file.tdy ] then TOUCH $file.tdy fi if [ `$DIFF -q $file $file.tdy | $WC -l` -gt 0 ] then $PERLTIDY $PERLTIDYOPTIONS $file if [ -e $file.ERR ] then echo Error detected-not replacing else if [ `$DIFF -q $file $file.tdy | $WC -l` -gt 0 ] then $CP $CPOPTIONS $file.tdy $file else echo Skipping replacement of $file - tidied file matches ori +ginal fi fi else echo Skipping $file - perltidy on file not necessary fi done else echo Usage: $0 filename [filename2] fi
Hope that helps.
|
|---|