xed 2.0.2 released!

xed is a perl script that locks a file, runs $EDITOR on the file, then unlocks it.

It also checks to see if the file is kept under RCS control. If not, it offers to make it so. RCS is a system that retains a history of a file. It is the predecessor to GIT, SubVersion, CVS and such. It doesn't store the changes in a central repository; it comes from a long-gone era before servers and networks. It simply stores the changes in a subdirectory called "RCS" in the same directory as the file. (and if it can't find that directory, it puts the information in the same directory as the file: named the same as the file with ",v" at the end.)

[More about this little-known tool after the jump.]

The benefit of keeping the change history of a file can not be understated. Can't figure out why a bug suddenly appeared? Now you can use commands like "rlog file", "rcsdiff -r1.2 -r1.4 file" and "co -p -r1.2 >oldfile" to examine old changes.

  • If you work on a team, xed's ability to lock files prevents you from stepping on each others toes.
  • If you work solo, xed's file history is a great way to keep track of changes.
  • If you work on a team, xed's file history is... well, a great way to add accountability to the system.

xed even notices when the last change to the file didn't happen via xed, and offers to clean up for you.

The new version adds a few features that I contributed:

  • Better security and the ability to edit filenames with spaces and funny characters (spaces, quotes, etc.) thanks to changing from Perl's system(string) calls to system(list) calls.
  • The ability to set the RCS changelog message via the environment variable CIMSG.
  • The ability to force non-interactive mode by setting an environment varialbe (INTERACTIVE=0. In non-interactive mode xed that assumes the defaults to any questions it asks.

These new features combine to let me do something I've always wanted to do: Friction-free updates to files: no prompts, no 'are you sure?', no request for changelog statements.

There are certain files that I need to update a lot. One example is my "cribnotes.txt" file where I log little notes that I want to remember later. It is always very tempting for me to get lazy and not record these notes. The rationalization I use is generally "Oh, it's a small note no worth my bother to answer all those 'are you sure?' and other questions. I can surely remember it without writing it down." Oh, how many times I've said that and not been able to remember it later. By making the editing process "friction-free", I don't have that excuse any more.

The alias I've set up is:

bash/ksh/sh: alias note='INTERACTIVE=0 CILOG="updated" xed ~/.cribnotes.txt'

csh/tcsh: alias note '( setenv INTERACTIVE 0 ; setenv CILOG "updated" ; xed ~/.cribnotes.txt'

Now I can simply type "note", record my thought, and save the file. No excuses.

xed is a godsend. It was originally written by the awesome programmer John Linderman at Bell Labs in ksh; later ported to Perl by Cliff Miller. The project page is here: http://www.nightcoder.com/code/xed/

I recommended it in TM4SA and I still recommend it today. No Unix system is complete without it.

Posted by Tom Limoncelli in Technical Tips

No TrackBacks

TrackBack URL: http://everythingsysadmin.com/cgi-bin/mt-tb.cgi/1157

2 Comments | Leave a comment

A friend uses a similar hack: cvi

Hi! How does this compare to rcsedit?

Leave a comment

 
LISA14 I'm Teaching button