XDG-OPEN'分段故障':花了很长时间然后扔错误

发布于 2025-02-02 18:15:54 字数 1140 浏览 2 评论 0原文

好吧,我注意到XDG-OPEN命令无法按预期的操作文件或URL工作 经过深入的调查,我发现以下

跟踪:

bash -x xdg-open "https://suckless.org"

运行上线后,我发现代码进入了无限的递归环,该循环会导致以SEG故障终止 问题的功能: /usr/bin/xdg-open:819,

for d in $dir/*/; do
    [ -d "$d" ] && search_desktop_file "$default" "$d" "$target"
done

但是为什么首先会发生这种情况,那很简单,我将在下面讨论

根本原因:

  1. XDG-OPEN尝试首先尝试获得全部目标应用程序的可能位置
    • 〜/.local/share/申请
    • /usr/local/share/申请
    • /usr/share/application
  2. 如果有任何孩子dir,它会递归递归,
  3. 当目录名称具有空间时,问题就会发生
    • 在我的情况下,就像这个

ls -la〜/.local/share/applications // wine // program // rockstar Games/
LS:无法访问 '〜/.local/share/applications // wine // program // rockstar':没有这样的文件 或目录游戏/:总计12 drwxrwxrwx 3 void void 4096 2月26日 19:54。 drwx ------- 43 void void 4096 5月29日12:32 .. drwxr-xr-x 5 void void 4096 5月24日22:36 Epic-Games商店 这使该工具可以在一个非常不同的文件中查找,从而使lop loop

循环循环

  • 更容易的修复是更改DIR名称并删除任何空间,如果您只能将桌面文件保留在〜/.local/.local/share//share/,则更好申请

well I noticed xdg-open command not working as expected for opnening files or urls
and after a deep investigation I found the below

Trace:

bash -x xdg-open "https://suckless.org"

after running the above line I found the code enters an infinite loop of recursion which cause to terminate with seg fault
the function with the problem:
/usr/bin/xdg-open:819

for d in $dir/*/; do
    [ -d "$d" ] && search_desktop_file "$default" "$d" "$target"
done

But why this happens in the first place, well it was fairly simple which I'm going to discuss below

Root Cause:

  1. xdg-open tries first to get all possible locations for target applications like
    • ~/.local/share/applications
    • /usr/local/share/applications
    • /usr/share/application
  2. if there's any child dir there it loop throug it recursively
  3. the problem happens when a directory name has a space
    • in my case it was like this

ls -la ~/.local/share/applications//wine//Programs//Rockstar Games/
ls: cannot access
'~/.local/share/applications//wine//Programs//Rockstar': No such file
or directory Games/: total 12 drwxrwxrwx 3 void void 4096 Feb 26
19:54 . drwx------ 43 void void 4096 May 29 12:32 .. drwxr-xr-x 5
void void 4096 May 24 22:36 epic-games-store
this got the tool to look up in a very different files which causes to loop infintly

Fix:

  • the easy fix is to change the dir name and remove any space, better if you can keep only desktop files inside the ~/.local/share/applications

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱,才寂寞 2025-02-09 18:15:55

修复:
简单的修复是更改DIR名称并删除任何空间,如果您只能将桌面文件保留在〜/.local/.local/share/应用程序中,更好的更好

Fix:
the easy fix is to change the dir name and remove any space, better if you can keep only desktop files inside the ~/.local/share/applications

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文