On Wednesday 27 July 2011 15:59, Dennis Groenen wrote: > On 07/23/2011 05:50 PM, Denys Vlasenko wrote: > > On Wednesday 13 July 2011 15:43, Dennis Groenen wrote: > >> On 07/13/2011 03:13 PM, Laurent Bercot wrote: > >>> Specialized filesystems such as jffs2 or yaffs2 still can, however. > >> Good point, but a lot of, for example closed, embedded/mobile devices > >> require a lot of hacking around to get something custom (like a > >> different fs) running. > >>> Why shouldn't it be? Either you want to reduce the number of writes > >>> to the filesystem, or you don't. Delayed writing, which is configured > >>> at the filesystem layer, accomplishes this for every application without > >>> the need for patching. Applications can always fsync() when they need > >>> synchronous writes. > >> True, but generally those writes from other applications are going to > >> happen anyway. E.g. if I save a file in application X, it will need to > >> be written out, and be written out completely. For BusyBox's history, > >> this isn't the case. I don't see why a file has to be written out after > >> each appended line here. Vi doesn't write out a file after each new line > >> either, does it? > > sh can crash. > > sh can be killed by a signal. > > sh can be run in parallel from two terminals, and saving at exit creates > > unfairness: whoever exits last overwrites the history of other guys. > > > The issues you've described are very valid, and are somewhat inevitable > when using volatile memory as a buffer. One needs to take these issues > into account when deciding whether to use a history buffer or not. > > > Nevertheless, I am not firmly against saving only on exit. > > Actually, I think that's the option you'd like. > > So, (1) it would largely solve your problem > > and (2) it would also be welcomed by people who like > > more bash-like behavior wrt history saving. > > > > Can you code up a patch which does this? > > I don't think I'm skilled enough to create a 'true' in-memory buffer to > temporarily store the history, i.e. one that doesn't use a regular file > in e.g. /tmp as the buffer.
You don't have to. The buffer already exists: it's state->history[]. > I'm assuming here that you didn't like the > way how I implemented saving history on exit in my original patch. Yes. It is completely unnucessary to create yet another file. All you need is to create a CONFIG_ option which disables "save history to disk after every command" behavior in remember_in_history() function, makes save_history() non-static and calls it on shell exit in both ash and hush. -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
