xdg-open breaks when trying to open hyphen-prefixed files.
Valid file names may include a hyphen -
at the start. xdg-open
mistakes these types of files to be a flag, giving an error:
$ mv -- example.png -example.png
$ xdg-open -example.png
xdg-mime: unexpected option '-example.png'
Try 'xdg-mime --help' for more information.
xdg-open: unexpected option '-example.png'
Try 'xdg-open --help' for more information.
Sane file-accepting CLI's use --
to stop parsing flags and parse all following arguments as files, even if they look like flags. Neither xdg-open
nor xdg-mime
support this convention:
$ xdg-mime query filetype -- -example.png
xdg-mime: unexpected option '--'
Try 'xdg-mime --help' for more information.
$ xdg-open -- -example.png
xdg-mime: unexpected option '-example.png'
Try 'xdg-mime --help' for more information.
xdg-open: unexpected option '-example.png'
Try 'xdg-open --help' for more information.
The current workaround is "don't do that" and keep all files from looking like flags. The better long-term solution would be to add support for --
to stop parsing flags and instead unconditionally parse the next argument as a file.