FreshJR
Very Senior Member
Every time you execute a command it gets stored in two locations.
I have the following alias that I use often
The following scenario has been bugging me enough for me to look into it.
I need to repopulate the history memory location as that is what is referenced when pressing UP/DOWN arrow.
I dug into the source code and confirmed this
Unfortuantly our history command does NOT take arguments.
https://ss64.com/bash/history.html
I would need to execute "history -r" according to that MAN page.
We already have the "-r" functionality coded in the source code, the problem is that there is no command/argument to reach the load_history function that is normally invoked by "history -r"
We have many brilliant people on this form. Has anyone hacked together a workaround?!?!
I tried but failed, is recompiling ash and replacing it the only way?
1) Stored in memory ( struct line_input_t -> char *history[MAX_HISTORY + 1]; )
2) Stored in HISTFILE (/tmp/home/root/.ash_history)
2) Stored in HISTFILE (/tmp/home/root/.ash_history)
I have the following alias that I use often
clr='clear && printf "\e[3J" '
The following scenario has been bugging me enough for me to look into it.
1) Execute command that fills up screen
2) Issue clr
3) Press up arrow
**4**) clr command cluttering history. I wish clr could be ignored
I thought it would be simple to purge it from the .ash_history file, but I found NO way to repopulate the memory location with the trimmed contents of the modified HISTFILE. Well besides restarting terminal, but that really isn't an option.2) Issue clr
3) Press up arrow
**4**) clr command cluttering history. I wish clr could be ignored
I need to repopulate the history memory location as that is what is referenced when pressing UP/DOWN arrow.
I dug into the source code and confirmed this
Code:
//ash.c
//ash terminal built in commands
//history terminal command executing corresponding historycmd function
static const struct builtincmd builtintab[] = {
{ BUILTIN_NOSPEC "history" , historycmd },
};
//ash terminal history actual function -- ignores parameters :(
historycmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
show_history(line_input_state);
return EXIT_SUCCESS;
}
//lineedit.c
//defines how terminal acts
extern struct lineedit_statics *const lineedit_ptr_to_statics; //terminal parameters, current input, cursor location, etc
//was defined in a hacky way to make a CONST declaration gain R/W ability
#define S (*lineedit_ptr_to_statics) //short way to access terminal parameters
#define state (S.state) //contains command history
// note: state member is of structure type "line_input_t"
// loads history present from hist_file when cnt_history is empty (happens upon terminal start)
# if ENABLE_FEATURE_EDITING_SAVEHISTORY
if (state->hist_file)
if (state->cnt_history == 0)
load_history(state);
# endif
// no access to this from ash terminal
static void load_history(line_input_t *st_parm)
{
...
...
}
Unfortuantly our history command does NOT take arguments.
https://ss64.com/bash/history.html
I would need to execute "history -r" according to that MAN page.
We already have the "-r" functionality coded in the source code, the problem is that there is no command/argument to reach the load_history function that is normally invoked by "history -r"
We have many brilliant people on this form. Has anyone hacked together a workaround?!?!
I tried but failed, is recompiling ash and replacing it the only way?
Last edited: