Bash 脚本不是从 nautilus 运行,而是从终端运行

Orf*_*fby 7 bash nautilus scripts shared-library

在我为我的问题添加更多细节之前,我必须说一些非常重要的事情:

是的,我的脚本打开了“允许作为程序执行文件”。

问题本身:

出于编程原因(共享库),我不能仅从可执行文件中执行我的程序,因为我需要LD_LIBRARY_PATH在执行程序之前进行访问。我创建了这个脚本来做到这一点(请记住,这是我第一次编写脚本):

#!/bin/bash
#Get the current directory and append the SO's location
currentDir=$(pwd)'/libs/'

#Change the library path
export LD_LIBRARY_PATH=$currentDir

#Run the program
./program
Run Code Online (Sandbox Code Playgroud)

从终端运行后,我认为它已经工作了,没有错误,程序也没有抱怨共享库。但不幸的是,如果我尝试.sh从 Nautilus双击该文件,则没有任何反应。最糟糕的是,因为我是从 GUI 运行它的,所以我不知道它得到了什么错误。我正在运行 Ubuntu 14.04,可执行文件是使用 SFML 库的 C++ 程序(是的,我可以只拥有依赖项,但 SFML 通常不安装在 Linux 计算机上,这不是重点)。

A.B*_*.B. 8

属性Allow executing file as program不够。

更改 Nautilus 首选项中的设置

在此处输入图片说明


或通过终端:

gsettings set org.gnome.nautilus.preferences executable-text-activation ask
Run Code Online (Sandbox Code Playgroud)