Skip to content

fish: Abbreviations with empty expansion produce invalid fish syntax #519

@anmayithap

Description

@anmayithap

Problem

The mkAbbrStr function unconditionally concatenates "${abbr.expansion}" at the end of the generated command:

mkAbbrStr = abbr:
  (foldl' (
    acc: elem: acc + " " + (mkAbbrArg elem abbr)
  ) "abbr --add ${abbr.word} ${mkCursorArg abbr}" abbrArgs)
  + " "
  + "\"${abbr.expansion}\"";

This causes two related problems:

  1. Empty string bug: When expansion = "", fish receives a trailing empty argument:
abbr --add dot-dot --regex "^\.\.+\$" ""
  1. --function incompatibility: Fish abbr --function does not require an expansion at all. However, because expansion is declared as types.str with no default, users must pass expansion = "" to satisfy the module, which then generates the invalid trailing "".

Reproduction:

{
  abbreviations.myabbr = {
    word = "myabbr";
    function = "my_function";
    expansion = "";  # forced to satisfy types.str, but meaningless to fish
  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions