leo-arch / clifm

The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell.
https://github.com/leo-arch/clifm/wiki
GNU General Public License v2.0
1.29k stars 41 forks source link

Plugins don't work with filenames that contain special characters #249

Closed bpn19 closed 10 months ago

bpn19 commented 10 months ago

Describe the bug Cannot open files which have spaces or other special characters in their name with plugins.

To Reproduce Steps to reproduce the behavior:

  1. Select a plugin such as img_viewer by copying it into ${XDG_CONFIG_HOME}/clifm/plugins
  2. Start CliFM
  3. Select a filename with special characters, for example: 'filename with spaces or [other] specials'
  4. Pass the filename to the plugin: i ELN or i 'filename with spaces or [other] specials'
  5. See (for example): feh WARNING: filename\ with\ spaces\ or\ \[other\]\ specials does not exist - skipping

Expected behavior Using plugins via their action name should work just as if they were called explicitly.

Desktop

Additional context Invoking a plugin explicitly inside CliFM like this: ${XDG_CONFIG_HOME}/clifm/plugins/img_viewer.sh ELN works as expected.

leo-arch commented 10 months ago

Hi @bpn19, and thanks for reporting.

Reproduced. I'll take a look at it.

EDIT: Does this happen only with this specific plugin?

leo-arch commented 10 months ago

Hey @bpn19! Two plugins (img_viewer.sh and wallpaper_setter.sh) are fixed (replace yours with the latest versions). Still a few more remain though.

Please give them a try.

bpn19 commented 10 months ago

Hey @leo-arch, thanks for quick response as always. I tested wallpaper_setter and it works no problem. However, when I try to use the new img_viewer, I get this diagnostic:

xargs: invalid option -- d
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements] [-S replsize]]
             [-J replstr] [-L number] [-n number [-x]] [-P maxprocs]
             [-s size] [utility [argument ...]]

Off the top of my head, vid_viewer was the other plugin I noticed giving me trouble with filename escaping. And for what it's worth, I also get tr: Illegal byte sequence whenever I use vid_viewer. Don't know whether it's worth opening another issue, I rarely use it anyway.

Lastly, although this is a bit off-topic, I noticed that there has been an open issue for a while about automated testing. I was thinking that some basic integration testing might pick up stuff like this? Due to health issues I am unable to directly contribute with e.g. pull requests etc. So these are just my thoughts. I appreciate the work that you do on this project.

leo-arch commented 10 months ago

Hey @bpn19, my bad. Didn't noticed you're running on FreeBSD: the Linux version of xargs do have the -d option, but not thus the POSIX version. Let me run a few tests on my FreeBSD box to see how to make it work there.

leo-arch commented 10 months ago

img_viewer should be working now (removed GNU specific option -d). vid_viewer still needs to be reworked.

EDIT: vid_viewer should be fixed now as well.

bpn19 commented 10 months ago

Hello @leo-arch, img_viewer and vid_viewer work with escaped characters now, thanks. I did notice a couple of typos in img_viewer:

Line 39 type sxivs should be type sxiv Line 58 xargs -0 img2sizel should be xargs -0 img2sixel

leo-arch commented 10 months ago

Thanks for pointing it out @bpn19! Fixed.