LPMuds.net
September 09, 2010, 04:15:19 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: This is the forum page. For the main LPMuds page, visit http://lpmuds.net
 
   Home   SITE FAQ INTERMUD DOWNLOADS LINKS Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: prompt/history bug in DS 3.0?  (Read 872 times)
Xenophanes
Acquaintance
*
Offline Offline

Posts: 5


View Profile
« on: February 07, 2010, 12:05:33 AM »

Greetings all,

  I couldn't find any reference to this, and I'm not seeing a bug tracker for DS, so I figured I'd post it here.  Please let me know if I should posting/searching elsewhere.

  I'm a big fan of history counters in my prompt, so I tried to set it up in my shell on DS 3.0.

Code:

/lib> prompt $C $N@$M:$P>
$C Xenophanes@XenoMUD:/lib>


Not exactly what I expected. So, I dug a bit and discovered in line 355 of /lib/nmsh.c:

Code:

    if(grepp(ret,"$C")) ret = replace_string(ret,"",itoa( CmdNumber+1 ));


I changed it to:

Code:

    if(grepp(ret,"$C")) ret = replace_string(ret,"$C",itoa( this_object()->GetCommandNumber() ));


But this hasn't completely solved the problem.  I get a command number now, but it isn't working properly.  It appears that the history related code was taken out of /lib/nmsh.c and put into /lib/history.c, and the history code doesn't appear to be working quite right.  Some commands get put into the history, and some don't.  I haven't worked out all the details of it yet.

I thought it would be a simple fix in /lib/nmsh.c, but it appears it will be more involved.  Has anyone seen this issue, or is anyone working on it? Is there anyone familiar enough with the history code to provide a little (ahem) history or status on it?

-X
Logged
Xenophanes
Acquaintance
*
Offline Offline

Posts: 5


View Profile
« Reply #1 on: February 07, 2010, 01:23:08 AM »

Ok, I see what's happening now.  The history isn't broken, it just doesn't work the way I expected it to.  I mistakenly assumed it worked the same way as a *nix shell history, but it doesn't; therefore, the $C piece is practically useless in reference to the history buffer. (my opinion, of course)

I still think linke 355 in /lib/nmsh.c is incorrect.

Does anyone have opinions on how the history and command numbers should actually work?  Is it fine for most people as is or is it something that's on the infinitely growing TODO list to fix?

-X
Logged
quixadhal
BFF
***
Offline Offline

Posts: 229



View Profile
« Reply #2 on: February 07, 2010, 05:01:22 AM »

I guess the question (for me) is, how does it currently work?

In the unix shell, the only reason I ever care about the command number is on the rare occasion I do something like !34, which means go execute entry 34 again.  If that isn't what nmsh does, I wouldn't even know how to form an opinion about it. Smiley
Logged

Xenophanes
Acquaintance
*
Offline Offline

Posts: 5


View Profile
« Reply #3 on: February 07, 2010, 05:15:43 AM »

That is "sort of" how it works, but not exactly.  The problem is the history is a fixed size of 50 (can be changed, but that's the default), but it doesn't act like a queue.  Instead, it renumbers every command.  So you'll always have commands 1-50 in your history list (assuming you've typed that many commands, of course).

To find out which command to execute, you can do a history, and then !34 to run the command.  However, !34 won't always equal the same command.  This is because of the way it was implemented.  You'd have to type history again, then look for the command to run... it might be 32 instead of 34 the second time around.

In a shell (i.e. csh or bash), !34 is always the same command, unless you run out of buffer space, in which case !34 is nothing.

In my opinion, command 50 should always be the exact same thing... until you've executed 50 more commands (to get to 100), in which case your history list should show commands 51-100, not 1-50.

I hope I'm making sense.  I can recode it, but don't want to waste the effort unless others see it as worthwhile.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!