1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

Make nix help shell work by handling aliases properly

Previously, `nix help shell` failed with "Nix has no subcommand 'shell'" despite `nix shell --help`
working correctly. This happened because the `shell` command is actually an alias for `env shell`,
and the help system wasn't resolving aliases when looking up documentation.

This patch modifies the `showHelp` function to check for and resolve aliases before generating the
manpage name, ensuring that shorthand commands like `shell` get proper help documentation.

Closes: #13431
(cherry picked from commit d678b071d6)
This commit is contained in:
Oleksandr Knyshuk 2025-07-17 17:26:56 +02:00 committed by Mergify
parent 17fc0f47cf
commit 31ea1d3fc8

View file

@ -212,6 +212,14 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs, virtual RootArgs
lowdown. */
static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
{
// Check for aliases if subcommand has exactly one element
if (subcommand.size() == 1) {
auto alias = toplevel.aliases.find(subcommand[0]);
if (alias != toplevel.aliases.end()) {
subcommand = alias->second.replacement;
}
}
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand));
evalSettings.restrictEval = false;