Hello, Here is a new version of the script.
While checking-in a file, it injects a sha-1 checksum in the log message. Also, it creates a copy of the current revision in ./RCS/ , and it adds a file with the sha-1 checksum, both properly named. Both files in ./RCS/ are redundant, but in this way one can more easily use different diff'ing tools (also, being redundant may not bad when one deals with long laboured writings). The script works for me, and I find it satisfactory for my needs. Please excuse the naiveté of the code, I am just an absolute beginner. Thank you again for your suggestions. Guido Sette Notes: - Any other checksumming tools could be use instead of sha-1 (I use sha1deep, since it is more flexible.) - I had to add special quoting using sed and awk, since I could not have the script work with file names with spaces.[1] - The script assumes an RCS directory. Also, the initial commit has been already done. Script follows below[2]. Further down, there is some code for testing the script. ###################################################### #! /bin/bash # # cic - "ci with checksum" # # cic file_name "revision log" # Sha1 checksum gets prepended before optional log message, $2 # File_name get expanded by $1 # Any other option to ci could be appended, like -l # # Use only after the initial commit # # The filename needs to be quoted in the following way, # Or else ci -m $1 will fail, due to wrong escaping. # Taken from Nautilus File Manager Scripts FAQ # http://g-scripts.sourceforge.net/faq.php # file[spaces]name in $1 gets properly quoted here, in $quoted quoted=$(echo -e "$1" | awk 'BEGIN { FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##) # Get file's checksum chksm=`sha1deep -q "$1"` # Check-in file, prepending checksum to log message # and temporarily store ci message eval "ci -m'$chksm- $2'" $quoted &> RCS/rev.tmp cd RCS # Get revision from ci message; get rid of tmp file # One just has to love awk! #rvsn=`awk '(/revision/) {print $2}' rev.tmp` rvsn=`awk '(/revision/) {print substr($3,1,3)}' rev.tmp` rm rev.tmp # co revision (unlocked) co -r$rvsn "$1" # Rename checkout as revision; -f because file is unlocked mv -f "$1" "$1".$rvsn # Write revision's checksum to disk as well sha1deep -q "$1".$rvsn > "$1".$rvsn.sha1 # un-unixesque trivial message, just to check # Delete when sure everything is hunky-dory echo Revision $rvsn of file "$1" has been checked-in with: echo Log msg: "$2" echo Checksum: $chksm echo The revision is also available as RCS/"$1".$rvsn ###################################################### Some testing: # cic - testing # Make sure RCS exists, and initial commit is done mkdir RCS touch filename\ with\ spaces.txt ci filename\ with\ spaces.txt # User needs to enter initial log here. # the three lines below ccould be applied a few times co -l filename\ with\ spaces.txt echo Add some lines >> filename\ with\ spaces.txt cic filename\ with\ spaces.txt "log message again." # checking results rlog filename\ with\ spaces.txt ls -al RCS [1] code by Paolo Bacch, from http://g-scripts.sourceforge.net/faq.php [2] Code can be found here as well: http://pastebin.com/UL52uFmN
