1

I am using a login session in my ash machine.

My problem is, when executing history command in ash shell, it returns 0. This is because the .ash_history is not created. I tried to triage the issue by debugging the ash.c code. Please find the code snippet of our interest. On analysis I found the Home directory is set to NULL, hence the underlined if condition is failed and ultimately reflects in .ash_history creation failure.

Code snippet of ash.c

 *#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
    if (iflag) {
        const char *hp = lookupvar("HISTFILE");
        if (!hp) {
            hp = lookupvar("HOME");
           ========================
            if(hp) {
           ===========
                hp = concat_path_file(hp, ".ash_history");
                setvar("HISTFILE", hp, 0);
                free(hp);
                hp = lookupvar("HISTFILE");
            }
        }
        if (hp)
            line_input_state->hist_file = hp;*

Can anyone help me in setting the HOME directory..If the home directory is some location, the if condition would have passed and .ash_history file will also be created, which resolves my issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.