XDG-OPEN'分段故障':花了很长时间然后扔错误
好吧,我注意到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
但是为什么首先会发生这种情况,那很简单,我将在下面讨论
根本原因:
- XDG-OPEN尝试首先尝试获得全部目标应用程序的可能位置
- 〜/.local/share/申请
- /usr/local/share/申请
- /usr/share/application
- 如果有任何孩子dir,它会递归递归,
- 当目录名称具有空间时,问题就会发生
- 在我的情况下,就像这个
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:
- xdg-open tries first to get all possible locations for target applications like
- ~/.local/share/applications
- /usr/local/share/applications
- /usr/share/application
- if there's any child dir there it loop throug it recursively
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修复:
简单的修复是更改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