Skip to content

cqfd: use CQFD_HISTFILE#250

Merged
florentsfl merged 2 commits into
masterfrom
fallard/use-cqfd-histfile-own-variable
Apr 20, 2026
Merged

cqfd: use CQFD_HISTFILE#250
florentsfl merged 2 commits into
masterfrom
fallard/use-cqfd-histfile-own-variable

Conversation

@florentsfl

Copy link
Copy Markdown
Contributor

The variable HISTFILE is not exported in most shells so cqfd cannot read it. And if we don’t use the same shell on the host and in cqfd then we don’t want to share the histfile. So it is more convenient to use CQFD_HISTFILE to set the HISTFILE in cqfd

@florentsfl
florentsfl force-pushed the fallard/use-cqfd-histfile-own-variable branch from 56bd06d to 7907f4f Compare November 26, 2025 20:35
@florentsfl

Copy link
Copy Markdown
Contributor Author

If we specify the variable CQFD_HISTFILE, should we bind mount this file in all cases ?

For now, a histfile is bind mounted only if we detect which shell is currently in use, for example when using cqfd <shell> or cqfd (run|exec) <shell>. It means that if we execute cqfd run "echo hello && bash" it will not bind mount the histfile.

But maybe we can consider that if a file was specified using CQFD_HISTFILE then it would make sense to bind mount it in all cases, whatever command is used after cqfd

@florentsfl
florentsfl force-pushed the fallard/global-tests-cleanup branch from 7aa0ae6 to ef46e16 Compare December 12, 2025 14:55
@florentsfl
florentsfl force-pushed the fallard/use-cqfd-histfile-own-variable branch from 7907f4f to 00d906a Compare December 12, 2025 14:55
@florentsfl
florentsfl force-pushed the fallard/global-tests-cleanup branch from ef46e16 to 54a337a Compare January 15, 2026 18:59
@florentsfl
florentsfl force-pushed the fallard/use-cqfd-histfile-own-variable branch from 2ffe904 to b14941d Compare January 15, 2026 18:59
@florentsfl
florentsfl force-pushed the fallard/global-tests-cleanup branch from 54a337a to ff86f51 Compare January 15, 2026 19:02
@florentsfl
florentsfl force-pushed the fallard/use-cqfd-histfile-own-variable branch from b14941d to e9a0753 Compare January 15, 2026 20:59
@florentsfl
florentsfl changed the base branch from fallard/global-tests-cleanup to master January 20, 2026 21:20
@florentsfl
florentsfl force-pushed the fallard/use-cqfd-histfile-own-variable branch from e9a0753 to 9c653f4 Compare January 20, 2026 21:36
The variable HISTFILE is not exported in most shells so cqfd cannot read
it. And if we don’t use the same shell on the host and in cqfd then we
don’t want to share the histfile. So it is more convenient to use this
variable to set the HISTFILE in cqfd
@florentsfl
florentsfl force-pushed the fallard/use-cqfd-histfile-own-variable branch from 9c653f4 to c204b14 Compare April 13, 2026 18:20
@florentsfl

Copy link
Copy Markdown
Contributor Author

If we specify the variable CQFD_HISTFILE, should we bind mount this file in all cases ?

For now, a histfile is bind mounted only if we detect which shell is currently in use, for example when using cqfd <shell> or cqfd (run|exec) <shell>. It means that if we execute cqfd run "echo hello && bash" it will not bind mount the histfile.

But maybe we can consider that if a file was specified using CQFD_HISTFILE then it would make sense to bind mount it in all cases, whatever command is used after cqfd

This will be the object of another PR

Comment thread README.md

`CQFD_SHELL`: The shell to be launched, by default `/bin/sh`.

`CQFD_HISTFILE`: This file will be used as the shell history file for all the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I'm correct, CQFD_DISABLE_SHELL_HISTORY was broken and didn't work unless the shell exported HISTFILE, which none do? Which shells did?
Maybe we can remove CQFD_DISABLE_SHELL_HISTORY and rather infer it as long as CQFD_HISTFILE is provided?
I think a traditional container approach is NOT to bind the host history by default. If we want to bind a host persistent history file by default, it could be a cqfd specific one, unless CQFD_HISTFILE explicitly points to the user's main history. By default, it could be ~/.cqfd_history

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

CQFD_DISABLE_SHELL_HISTORY was working as expected:

cqfd bash -> bind mounts the default bash history file -> I can use up arrow to navigate history
CQFD_DISABLE_SHELL_HISTORY=true cqfd bash -> does not bind mount the default bash history file -> up arrow does nothing

it is just that cqfd was trying to read HISTFILE to set the file to bind mount, but if HISTFILE did not exist then it used the default path of the shell history file for different shells:

cqfd/cqfd

Line 757 in 8692828

shell_histfile="${HISTFILE:-$HOME/.${program_basename}_history}"

But no shell is exporting HISTFILE, so cqfd was always using the default value provided to bind mount the history file.

This PR was just about fixing this behavior which made cqfd always use the default hardcoded histfile path because HISTFILE is never exported.

It is true that we should discuss about which file we bind mount (project-specific, cqfd-specific or user one), and in which circumstances (by default or not), but this PR just intended to fix an erratic behavior.

A simpler version of this PR could also just remove the variables HISTFILE and CQFD_HISTFILE to only use default values hardcoded in cqfd, which is the current behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, I don't fully agree with the decision to bind the host history file as a default behaviorr, but since it has already been merged, a fix is welcome.
I have concerns regarding the pollution of the host history, or exposing sensitive commands information inside the container.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I configured my own environment to have a default separate file for cqfd history: ~/.cqfd_history. If other users/maintainers agree, we could turn this into a default.

@florentsfl
florentsfl merged commit c474e9a into master Apr 20, 2026
2 checks passed
@florentsfl
florentsfl deleted the fallard/use-cqfd-histfile-own-variable branch April 23, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants