Bash-it / bash-it

A community Bash framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dnf aliases cause ambiguous redirect with help subcommand in Fedora 35

wallon-ines opened this issue · comments

Hello,

If I want run this command bash-it help plugins, I have this error:

please wait, building help...bash: $grouplist.$group: ### ambiguous redirect

quiet               what *does* this do?
usage               disk usage per directory, in Mac OS X and Linux

battery:
battery_charge      graphical display of your battery charge
battery_percentage  displays battery charge as a percentage of full (100%)

composure:
cite                creates one or more meta keywords for use in your functions
draft               wraps command from history into a new function, default is last command
:cat: '/tmp/grouplist.VHNdCz.|': No such file or directory
cat: groups: No such file or directory
cat: '|': No such file or directory
cat: grouperase: No such file or directory
cat: '|': No such file or directory
cat: groupinfo: No such file or directory
cat: '|': No such file or directory
cat: groupinstall: No such file or directory
cat: '|': No such file or directory
cat: grouplist: No such file or directory
cat: '|': No such file or directory
cat: groupremove: No such file or directory
cat: '|': No such file or directory
cat: 'groupupdate)': No such file or directory

This problem appear if enable dnf's aliases and I don't know enough about this code for create a new PR.

Step to reproduce

  • Adduser test
  • Install bash-it
  • Run bash-it help plugins, result : No errors
  • Enable dnf aliases bash-it enable alias dnf
  • Reload bash-it bash-it reload
  • Re run bash-it help plugins and I see this error
  • If I run all_groups I see :
    Screenshot from 2022-01-16 15-24-22

Hi @wallon-ines thanks for taking a minute to report your issue.

Looking at:

I believe the issue stems from this code in the bash completion script:

function _dnf()

case "$command" in
    ...
    group|groups|grouperase|groupinfo|groupinstall|grouplist|groupremove|groupupdate)
    ...

Although the source code has no spaces between the options, when reformatted via typeset -f (used in the plugin helper), bash adds spaces:

$ typeset -f _dnf

    ...
    group | groups | grouperase | groupinfo | groupinstall | grouplist | groupremove | groupupdate)
    ...

The spacing ends up causing this line to match our metafor group metadata extractor, used in the helper function (and in the all_groups function):

$ typeset -f _dnf | metafor group

| groups | grouperase | groupinfo | groupinstall | grouplist | groupremove | groupupdate)

This gets assigned to the $group variable in the helper function, then causes problems when used later in the function:

        _letterpress "$about" $func >> $grouplist.$group
        echo $grouplist.$group >> $grouplist

NOTE: At this time, I think its pure coincidence, and not related to the issue, that the helper function creates and uses a variable named grouplist :

    typeset grouplist=$(mktemp -t grouplist.XXXXXX)

And, although I'm confident the issue related to the bash completion function, its not clear to me how/why the issue relates to the enabling/disabling of the dnf aliases.

Perhaps our alias-completion logic somehow invokes the bash completer when it might otherwise not have been active?

@wallon-ines Could you do a test with a fresh session with the aliases disabled, confirming bash-it help plugins works, then try to invoke the dnf bash completions (i.e try some dnf commands pressing tab to complete the options), and then try bash-it help plugins again?

We've just merged a complete overhaul to the alias completion code. Could you (a) give it a try, (b) let us know if it changes anything with these errors?

closed as no response was given