Skip to content

Add API to allow reading & writing history to file#9

Open
jeanbaptistelab wants to merge 52 commits intomasterfrom
feature/SI-4830-persist-csh-command-history-across-session-a-la-b
Open

Add API to allow reading & writing history to file#9
jeanbaptistelab wants to merge 52 commits intomasterfrom
feature/SI-4830-persist-csh-command-history-across-session-a-la-b

Conversation

@jeanbaptistelab
Copy link

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.

@Lykkeberg
Copy link

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 🫣

@Lykkeberg
Copy link

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.

Copy link
Author

@jeanbaptistelab jeanbaptistelab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

@jeanbaptistelab jeanbaptistelab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jeanbaptistelab jeanbaptistelab force-pushed the feature/SI-4830-persist-csh-command-history-across-session-a-la-b branch from 7247cc9 to 4d7e805 Compare August 2, 2024 21:17
jeanbaptistelab and others added 21 commits August 12, 2025 15:00
…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"
johandc and others added 30 commits August 12, 2025 15:03
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.
* Remove unneed header inclusion

* Add currently not active warning in anticipation of dflopt.h header deprecation
)

* Extend slash to allow use of custom options handling

* Remove duplicate line
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants