Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m_option: deprecate OPT_PATHLIST #15868

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Dudemanguy
Copy link
Member

mpv has always had a separate type, OPT_PATHLIST, for paths/files. It worked exactly like OPT_STRINGLIST except that it used : (unix) or ; (windows) as a separator. There is no reason to have this distinction. : is allowed in filenames on linux and ; is allowed on windows so it is not even like these characters guarantee no escaping. Instead, we should be consistent and use one separator (,) for everything. In the option parsing, add some old compatibility code for the old path-specific separators with a warning that it is deprecated and , is preferred. It's not perfect. Someone using paths with , in them would now need to escape them, but it's about the best we can do realistically. Remove all references to path lists in the documents and treat it exactly like the normal string list option.

Copy link

github-actions bot commented Feb 14, 2025

Download the artifacts for this pull request:

Windows
macOS

@@ -1438,6 +1438,21 @@ static char **separate_input_param(const m_option_t *opt, bstr param,
str = bstr_cut(str, 1);
n++;
}
// Backwards compatibility for path list options.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work in practice. There is no sane way to provide backward compatibility.

If you had a list separated with ; you likely didn't have , escaped, so it will already break the list in the main loop above.

By doing this we basically force to escape both separators.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. It's mentioned in the commit message. There is breakage no matter what, but I figured it was worth at least trying if the user doesn't have , in there.

Copy link
Contributor

@kasper93 kasper93 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really annoying, change like that will break everything. And even if compatibility is provided, all users are expected to migrate. ¯⁠\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯

Honestly we might be stuck with it forever.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there really that many people that use paths with , in them? I know the number isn't zero, but I feel it shouldn't be too many. We can always wait a couple of stable releases or so before yanking it.

Copy link
Contributor

@kasper93 kasper93 Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean in general switch from :/; to ,. Scripts/configs and so on... Though I like the change, because I always needed to check what is the separator for option X and system Y..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be some pain but I think it's for the greater good.

mpv has always had a separate type, OPT_PATHLIST, for paths/files. It
worked exactly like OPT_STRINGLIST except that it used : (unix) or ;
(windows) as a separator. There is no reason to have this distinction. :
is allowed in filenames on linux and ; is allowed on windows so it is
not even like these characters guarantee no escaping. Instead, we should
be consistent and use one separator (,) for everything. In the option
parsing, add some old compatibility code for the old path-specific
separators with a warning that it is deprecated and , is preferred. It's
not perfect. Someone using paths with , in them would now need to escape
them, but it's about the best we can do realistically. Remove all
references to path lists in the documents and treat it exactly like the
normal string list option.
@na-na-hi
Copy link
Contributor

na-na-hi commented Feb 14, 2025

I don't think this compatibility break is worth it. Many of these options are very commonly used. The overhead to support custom separators is minimal so there is really no benefit of removing it.

Also technically path separator characters are allowed in files, but because the pervasive use of these separators in the software ecosystem as a whole, there are more file names in the wild which contain , but not : or ; (and most would want to avoid : because it's illegal in Windows) to avoid this issue, which means more escaping is needed.

A better option would be adding an option to allow custom path separators. Those who prefer consistency with string list options can set it to ,.

@kasper93
Copy link
Contributor

kasper93 commented Feb 14, 2025

I don't think this compatibility break is worth it. Many of these options are very commonly used. The overhead to support custom separators is minimal so there is really no benefit of removing it.

I think it is not a problem of overhead to support those. But fragmentation of mpv string/path options. You always need to actively think what is the correct separator for given option and on top of that it is different on different OSes which makes thing not portable between them. See #10450 (comment) for example, people are confused. And since mpv config is driven by guides and suggestions from others, it's not obvious for the user, why this option works for them, but not the other guy.

But I agree, compatibility break here is pita. Also , are indeed more common in filenames generally than ; or : would.

I don't have strong opinion either way. I like the idea of single separator to make the use of it easier and portable. But on the other hand forcing users to change their stuff is annoying outcome.

@Dudemanguy
Copy link
Member Author

Dudemanguy commented Feb 15, 2025

This is the total count of files on my system excluding root stuff (i.e. my home folder + mounted drives) that have these characters.

: , ;
370 2915 532

So the current status quo of using : on unix, at least for me, is by far the worst. I guess it's a safe bet that ; is in general the least common for most people though.

Edit: Sorry my bad I forgot I had a bunch of chroots in a subdirectory so that's a bunch of bogus OS files. So comma is indeed the most by this count.

@kasper93
Copy link
Contributor

Edit: Sorry my bad I forgot I had a bunch of chroots in a subdirectory so that's a bunch of bogus OS files. So comma is indeed the most by this count.

The closes to mpv example of files with , would be files downloaded with ytdl. It puts title in the file name, I have files with , and : just looking at a few laying around. Though I know they do sanitization of files names too, but obviously not for , which is valid character.

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.

3 participants