Add API to allow reading & writing history to file#9
Add API to allow reading & writing history to file#9jeanbaptistelab wants to merge 52 commits intomasterfrom
Conversation
|
This is a neat feature. We have to remember that the CSH can be used in a lot of different contexts at the same time, so if this is going to be extra, super smart, I think we should name the history files with some context information along side the placement of where it has been invoked. But I'm not fully aware of how 🫣 |
|
These history files could also potentially end up containing sensitive information to some customers, so how do we protect that? If say, a command to VM is being entered with a password, then this would be forever locked into a history file. I'm not sure that is a problem or not, but it is something we need to consider. |
There was a problem hiding this comment.
This is a neat feature. We have to remember that the CSH can be used in a lot of different contexts at the same time, so if this is going to be extra, super smart, I think we should name the history files with some context information along side the placement of where it has been invoked. But I'm not fully aware of how 🫣
This implementation does not set the location or name of the history file, this is entirely up to users (mainly CSH) to either:
- not use it ;)
- use it with their own file location, naming policy.
This change also does not change any current behaviour (apart from checking for NULL when adding to the history) so this change should be fairly safe.
jeanbaptistelab
left a comment
There was a problem hiding this comment.
These history files could also potentially end up containing sensitive information to some customers, so how do we protect that? If say, a command to VM is being entered with a password, then this would be forever locked into a history file. I'm not sure that is a problem or not, but it is something we need to consider.
A few things can be done:
- write a function that processes the line to be added to the history and guess whether some tokens look like password and replace them with "*"
- the user (CSH) can (temporarily) disable persisting the history for the next few commands and turn it back on again (the "history_file" pointer is part of the "struct slash", so saving it to a temp variable, setting it to NULL for the next few commands and restoring it is feasable. I'm contemplating extending the already existing built-in "history" command to add this functionality
7247cc9 to
4d7e805
Compare
…his is easier to understand and extend
…eter function, the new line print is actually the completion completer function's responsibility
Simply used calloc() instead of malloc(), this makes Valgrind slightly happier.
…lready compleing" (aka "watch get<TAB>") configurable
no matter how long time the command takes to execute
…eparated. Without this fix, it is not possible to use the following: get -n135
* Add a configurable mechanism that applications can use to modify the actual command line about to be slash-executed. * Typo in comment * Add support for an optional "global" completion function * Initialise variable, caught by PR review
…ultiple completions are found, causing the slash_path_completer function to print on the same line as the cmd line, which is confusing.
…refix* match, leading to typing things like "listttt" being interpreted the same as "list"
Catch the SIGINT outside of slash and then call slash_sigint to pass signals down, for the usual CTRL+C behaviour in slash.
… partial user input up to the found completion string For example: - user types in "clea" - there is only one possible completion, "clean" - then fill up the string with the rest of the completion, a.k.a "clean"
Not that slash knows anything of these, but this is the way to document them for now.
… hostname tab-completion (#17)
* Remove unneed header inclusion * Add currently not active warning in anticipation of dflopt.h header deprecation
… related functions This change configures slash's history size to what the user asks - 1 but still allocates the originally requested memory amount... Found with valgrind
- comparison of integer expressions of different signedness - unused parameter
… by slash - useful for APM that need the "normal" stdin/stdout descriptors (for example, an embedded Python interpreter)
Currently no function to use it, but a struct initializer will suffice.
Not used internally, to be implemented by user.
Implement bash history-like feature in Slash: commands will be saved on disk and read when calling the new Slash API (slash_init_history_from_file)
There will be a counter-part in CSH that uses this new feature once this PR is merged.