[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: editing log message

From: Bob Proulx
Subject: Re: editing log message
Date: Fri, 8 Jun 2007 22:12:47 -0600
User-agent: Mutt/1.5.9i

I don't read help-rcs regularly and so this is a delayed response to a
posting from last month.

address@hidden wrote:
> I've been using RCS for ages now, but I'm having trouble editing the log
> message on one system.

That implies that it works differently on other systems?  I would
expect it to work the same on all systems.

> If I log into this computer (a Linux system running RCS v5.7), and
> check in a file, it of course gives me the usual '> ' prompt to type
> in my log message.

Yes.  The read-one-line-at-a-time input method of rcs that we all know
and don't like very well today.  But typical of the time 25 years ago
when rcs was introduced to the world.  For 25 years old this is not

I hate to suggest this on the help-rcs list but I think it is true so
I will say that most people today use a more modern version control
system than rcs.  Today I dare say that rcs exists to support the
legacy use of it but it is not recommended for new instances.  Today
you would be better off using Git or Subversion or one of the others.
It is because these new systems have come into being that rcs is
maintained only enough to keep it going but not to add new features to
it.  I think the last rcs change was in 1996.  I recommend that you
consider using a more modern system such as Git if you have the choice
to do so.

> It basically works OK, unless I make a misteak (believe it or not,
> sometimes I misspell things).

Yes.  Inconvenient that rcs does not spawn an editor to edit the
message.  You basically can't make a mistake.  It reads input line by
line and whatever you type in goes into the log message.  This
includes mistakes.  This includes cursor escape sequences.

> If I'm running on a tty like puTTY or SSH Shell client, I can use
> the backspace key, but nothing much else works: not the cursor
> arrows (which give me on-screen characters like '^[[C' or '^[[A'--I
> believe these are the ANSI escape sequences for cursor control).

Well, actually those cursor keys emit escape sequences.  If you press
them and enter those cursor key escape sequences into your log message
then they will literally be in your log message!  That is almost
certainly not what you want.  You can backspace many times and remove
them.  Since you can't see some of them you would need to backspace
more than the characters that you can see to remove them all from the
input buffer.

If you have been doing this with files that you care about then you
might want to go back and fix up those log messages.  They will almost
certainly have junk characters in them.  Log messages may be edited by
using the 'rcs' command.

  rcs -m1.42:"$(<logmessagefile)" somefile

You would need to select each file revision individually though.  That
would be a pain.  This could be automated to some extent using scripts.

> If I'm running an X-Win32 terminal, it's even worse: not even the
> backspace or delete chars work.  (I have the XKeyboard extension turned
> off.)

That would probably be a configuration bug in your terminal then.  I
am not familiar enough with that terminal type to suggest a way to
debug, diagnose and fix it though.  You are on your own there.

> I suppose this is more of a tty problem than it is a problem with RCS,
> except for one thing: these keys work fine for editing if I'm at the
> bash-prompt level.

But Bash is a screen editor.  Bash reads the terminfo/termcap database
and handles your command line input in the same way that a screen
editor would.  Therefore it is not really a fair comparison.  Saying
that bash handles the input is also like saying that emacs/vi handles
keyboard input.  They are basically the same.

By contrast rcs is not a screen editor.  The rcs commands are simply
reading your lines one by one from your keyboard.

> So something is different between the way bash does a readline and
> the way 'ci' does.

They are very, very much different.  Hugely different.  Almost to the
point of no longer being related to each other.  (Yes, I am
exaggerating here but not far from the truth.)

> If I could make 'ci' read the log message as I type it interactively
> the same way 'bash' reads the command line, I would be home free.

Bash links with libreadline.  rcs does not.  You could use a
libreadline wrapper application such as 'rlwrap' to edit single lines but
that still is not what you would want because you would want your log
message to span multiple lines.  Notice that in bash it only edits one
line at a time.

> I've tried editing my .inputrc file, but it seems to have no effect at
> this level (it does affect the editing of the command line in bash, of
> course).

The $HOME/.inputrc file affects libreadline used by bash and others
but rcs does not use libreadline.  Therefore the .inputrc file will
have no affect on rcs.

> So my question is, what input routine is 'ci' using for reading in the log
> message,

The ci command uses getc() to read input character by character.

  man getc

> and how can I tell it what to do with control key and cursor
> sequences?

You can't.  And basically you would not want it to do that.  Really
you would want ci to invoke $EDITOR so that you can edit the message
with your preferred editor.

> I would be happy (OK, happier) if I could just get it to recognize
> the backspace key in an X-Win32 terminal.

If it is a normal terminal then you can ask it with 'stty -a' what
parameters are set.  here is an example from my terminal.

  stty -a
  speed 38400 baud; rows 24; columns 80; line = 0;
  intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
  ... rest of output removed ...

See that part "erase = ^?".  That is the important part.  My terminal
uses ^?, the Delete character (aka DEL) as the erase character.  Some
terminals use the ^H, the backspace character (aka BS) as the erase
character.  Probably your erase character is not matching your
terminal setting.  Or the reverse.

IIRC Bash uses all of DEL, BS, or the tty erase character.  This is
why bash would appear to work even when things are misconfigured.  No
bug reports to bash in that case even though it is technically
incorrect for doing so.

> Even better would be full use of cursor/ control keys.

What you really want to do is to spawn an editor and to edit your log
message in an editor.  It is unfortunate that rcs does not provide
this feature by default.  But since rcs is 25 years we can forgive it
for being terse.  Back then people who used computers were real
hackers and knew to never make a mistake.  If they did they knew to
use 'ed' to get their log message into shape and replace it.  :-)

As Colin Brough pointed out in his followup, emacs has built in
support for dealing with rcs files.  Using emacs to check in the file
means that a full featured editor is available.  This is by far the
most convenient way to edit log messages and to check in files.

If you are not an emacs user however this can be done almost as nicely
with a few commands.

  $EDITOR logfilemessage
  ci -m"$(<logfilemessage)" yourfile

You could create a script of the above to automate this.  This
following is an example that might give you some ideas.

  trap 'rm -f $TMPFILE' EXIT
  TMPFILE=$(mktemp) || exit 1
  ci -m"$(<$TMPFILE)" yourfile
  exit $?

Hope that helps,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]