Skip to content

fish: don't enable private mode when --no-config is set - #12741

Open
ChrisJr404 wants to merge 1 commit into
fish-shell:masterfrom
ChrisJr404:fix-no-config-no-private-mode
Open

fish: don't enable private mode when --no-config is set#12741
ChrisJr404 wants to merge 1 commit into
fish-shell:masterfrom
ChrisJr404:fix-no-config-no-private-mode

Conversation

@ChrisJr404

Copy link
Copy Markdown

Closes #12711.

fish --no-config -c 'set -g fish_history fish; history merge' errors with history: can't merge history in private mode. The reporter expects --no-config to skip default config dirs without touching history behaviour; --private already covers the no-history case.

The cause is in src/bin/fish.rs. The -N / --no-config arm sets both opts.no_config and opts.enable_private_mode:

'N' => {
    opts.no_config = true;
    // --no-config implies private mode, we won't be saving history
    opts.enable_private_mode = true;
}

The documented behaviour of --no-config (doc_src/cmds/fish.rst) is just "Do not read configuration files." There is no docs note that says --no-config should imply private mode, and --private is the documented way to opt into "fish will not access old or store new history."

The patch drops the implicit enable_private_mode = true. --private still triggers private mode on its own, and --no-config --private together still produce a private no-config shell.

Verification

Before:

$ ./fish --no-config -c 'set -g fish_history fish; history merge'
history: can't merge history in private mode

After:

$ ./fish --no-config -c 'set -g fish_history fish; history merge; echo OK:$status'
OK:0

$ ./fish --private -c 'set -g fish_history fish; history merge'
history: can't merge history in private mode

$ ./fish --no-config --private -c 'set -g fish_history fish; history merge'
history: can't merge history in private mode

Tests

Extended tests/checks/no-config.fish to assert fish_private_mode is unset under --no-config and that history merge succeeds.

Full local run: python3 tests/test_driver.py target/release -> 242 / 242 passed (6 skipped).

Changelog

Added a bullet under the unreleased section in CHANGELOG.rst.

`--no-config` skips reading user/system config files. Until now it also
flipped on private mode, which blocks history reads/writes and breaks
`history merge`. The documented purpose of `--no-config` is only to skip
configuration; users who want a no-history session already have
`--private`.

Stop setting `enable_private_mode` from the `-N` branch. `--private`
still enables private mode on its own, and combining both flags still
gives a private no-config shell.

Closes fish-shell#12711

Signed-off-by: ChrisJr404 <chris@hacknow.com>
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.

--no-config enables private mode which prevents history from being read and written

1 participant