events - 对发出的事件做出反应时,Unix Dialog 实用程序在 fish shell 中失败
问题描述
我有这个功能(已知工作正常)
function problem_open -e on_problem_open -d "select from existing problems"
set matches (find $FD_PROB_HOME/ -maxdepth 1 -mindepth 1 -type d ! -name ".git")
if test 1 -eq (count $matches)
if test -d $matches
set -U FD_PROB_CURRENT $matches[1]
echo "chose option 1"
return
end
end
set -g dcmd "dialog --stdout --no-tags --menu 'select the file to edit' 20 60 20 "
set c 1
for option in $matches
set l (basename "$option")
set -g dcmd "$dcmd $c '$l'"
set c (math $c + 1)
end
set choice (eval "$dcmd")
#clear
if test $status -eq 0
echo "edit option $choice"
set -U FD_PROB_CURRENT $matches[$choice]
end
end
当我直接调用时problem_open
,对话框显示正常。当我间接调用该函数时,emit on_problem_open
不会显示通过对话框。
任何想法为什么会发生这种情况?它是事件的预期行为吗?
我可以解决这个问题,但这将是一个棘手的问题。
解决方案
您的示例在这里可以,但一个提示是确保该函数是手动定义的或在您的 中定义的config.fish
,而不是依赖它来自动加载。存储在自动加载文件中的函数在第一次运行之前不会监听事件处理程序。
推荐阅读
- c# - 通过 IDs 集合查询对象的 Realm
- c# - 非空约束列中存在值但 Postgres 抛出异常
- c# - 如何按某个属性对表进行分组,然后计算 LINQ 中另一个表(带有外键)中存在的那些元素?
- awk - 在 awk 中,你可以同时使用一个模式和一个 END 块吗?
- azure - Azure DevOps 管道构建工件中缺少 Gulp 编译的 CSS 文件夹
- twitter-bootstrap-3 - 网格自动对齐到多行
- ios - iOS:为什么我的活动视图控制器(self)在使用downloadTask下载视频时采用单例(sharedInstance)的地址?
- java - POJO 是否应该连接到视图或控制器?
- php - 如何在 laravel 中建立关系
- android - 在数组中查找重复值并将它们打印到android中的列表视图