mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.54k stars 2.86k forks source link

Filenames are not tab-completed if "=" present after the option #7955

Open lgbaldoni opened 4 years ago

lgbaldoni commented 4 years ago

Important Information

Provide following Information:

If you're not using git master or the latest release, update.

the relevant file (etc/mpv.bash-completion) appears to be the same as master

Reproduction steps

Try to reproduce your issue with --no-config first. If it isn't reproducible with --no-config try to first find out which option or script causes your issue.

the problem occurs before launch

Describe the reproduction steps as precise as possible. It's very likely that the bug you experience wasn't reproduced by the developer because the workflow differes from your own.

type mpv testfile.mpv --sub-file= and hit tab.

Expected behavior

Filename to be completed.

Actual behavior

Nothing happens.

Log file

Does not apply.

Sample files

Does not apply.

CounterPillow commented 4 years ago

this is a problem with your shell's tab completion. You can use the legacy option syntax -sub-file to work around this.

lgbaldoni commented 4 years ago

this is a problem with your shell's tab completion. You can use the legacy option syntax -sub-file to work around this.

Error parsing commandline option sub-file: option requires parameter
Make sure you're using e.g. '--sub-file=value' instead of '--sub-file value'.

Could you be more specific about shell problem? It's bash 4.4.23: is it too old? Or should I set some variable?

lgbaldoni commented 4 years ago

5.0 is latest, lol.

Not everyone uses rolling releases distros. Can you confirm mpv requires bash 5.0 for its bash completion to function properly?

avih commented 4 years ago

Could you be more specific about shell problem? It's bash 4.4.23: is it too old? Or should I set some variable?

The issue is that --foo bar used to work, but now if two -- are used for an option which takes a value, then it must be used as --foo=bar. Additionally -foo bar always worked as well, and still works.

Some shells don't try to complete immediately files after =, at which case you can use the alternative syntax of -foo bar (note: one - and not two) which would restore your shell completion.

lgbaldoni commented 4 years ago

The issue is that --foo bar used to work, but now if two -- are used for an option which takes a value, then it must be used as --foo=bar

Will it work with bash 5.0? Does it work for you?

at which case you can use the alternative syntax of -foo bar

Actually no, mpv complains about the missing = and exits.

avih commented 4 years ago

at which case you can use the alternative syntax of -foo bar

Actually no, mpv complains about the missing = and exits.

Are you sure? For me mpv --log-file=my.log and mpv -log-file my.log work, while mpv --log-file my.log fails because = is not used.

CounterPillow commented 4 years ago

Actually no, mpv complains about the missing = and exits.

Post what you typed in then, and the output it gave. If mpv doesn't accept legacy option syntax, it's a bug, but to confirm that's what's happening, we need you to post you trying to use legacy option syntax, which I am 99.9999% sure you're not and you're still typing two dashes.

lgbaldoni commented 4 years ago

@CounterPillow you were right, legacy syntax works.

But it's going to be phased out at some point, I suppose. Is it a matter of bash version for the new one to work? Or possibly some variable to set?

philipl commented 4 years ago

This is a gap in the bash completion, but it could be made to work with some effort.

lgbaldoni commented 4 years ago

@philipl sorry, a "gap" with what?

Could someone please tell me if the problem is with bash, with the bash-completion script coming with mpv or yet something else?

philipl commented 4 years ago

A functional gap. It doesn't handle options that take a filename today. Someone would have to write new logic into the bash-completion script to handle it.

lgbaldoni commented 4 years ago

Ok, so it is a real bug.

@CounterPillow does it work for you?

philipl commented 4 years ago

For completeness, we do auto-complete files for options that have a [file] type, but options such as sub-file aren't like that, so we need additional logic to detect them correctly.

philipl commented 4 years ago

Concretely, that means you could use --sub-files= and that would autocomplete. --sub-file is an alias for --sub-files-append which means it adds to the existing list while --sub-files= replaces the list. Depending on your use-case, that may be fine.

lgbaldoni commented 4 years ago

@ValZapod Couldn't find mpv in the package filelist here.

Besides that, can you confirm that you have a working bash completion for mpv on debian sid?

CounterPillow commented 3 years ago

But it's going to be phased out at some point, I suppose

As far as I remember, it has been un-deprecated (it used to have a warning before) and will remain around specifically for simple tab completion reasons.