为什么几乎所有共享库/usr/lib/都设置了可执行权限位?我没有看到任何执行它们的用例。有些确实设法连接某种形式的main功能来打印简短的版权和版本说明,但许多甚至不这样做并且在执行时出现段错误。
那么,设置这个有x什么意义呢?所有的库打包者都必须这样做吗?如果我dlopen()是一个有0644权限的共享库会发生什么?
我有一个包含以下文件夹结构的小程序:
- main.sh
- lib/
- clean.sh
- get.sh
- index.sh
- test.sh
Run Code Online (Sandbox Code Playgroud)
每个文件都包含一个我在main.sh.
main.sh:
source lib/*
get_products
clean_products
make_index
test_index
Run Code Online (Sandbox Code Playgroud)
在上面的前两个函数中,后两个函数不起作用。
但是,如果我替换source lib/*为:
source lib/get.sh
source lib/clean.sh
source lib/index.sh
source lib/test.sh
Run Code Online (Sandbox Code Playgroud)
一切都按预期工作。
有谁知道为什么source lib/*不能按预期工作?
我在 linux (ubuntu) 中使用 Microsoft 的 dotnet,它具有拨号家庭遥测功能。我想禁用它,说明说:
.NET Core 工具收集使用数据以帮助我们改善您的体验。数据是匿名的,不包括命令行参数。数据由 Microsoft 收集并与社区共享。您可以通过使用您喜欢的 shell 将 DOTNET_CLI_TELEMETRY_OPTOUT 环境变量设置为“1”或“true”来选择退出遥测。
我读过.profile,.bashrc,.bash_profile,/etc/environment,等,在被读取后,他们的差异,如果在所有。
所以我不知道该放在DOTNET_CLI_TELEMETRY_OPTOUT=1哪里?我希望它始终被加载,无论我是否在没有桌面的情况下登录、使用桌面登录、远程 ssh 登录、启动终端、从父终端启动终端等。
我应该把它放在哪个文件(或多个文件)中?我将如何为所有用户执行此操作?
从跑步help .或help source
从当前 shell 中的文件执行命令。
在当前 shell 中从 FILENAME 读取和执行命令。$PATH 中的条目用于查找包含 FILENAME 的目录。
从我的角度来看,似乎 dot 命令(或source命令)只是在当前 shell 上下文中运行一个 shell 脚本(而不是生成另一个 shell)。
问题:为什么.(或source)不要求文件像运行普通脚本一样可执行?
在脚本末尾删除 shell 脚本中使用的变量是否好。
rm -rf $abc
rm -rf $def
Run Code Online (Sandbox Code Playgroud)
或者
unset $abc
unset $def
Run Code Online (Sandbox Code Playgroud)
等等。
这实际上是一个好习惯吗?
查看我/etc/profile.d目录中的文件:
cwellsx@DESKTOP-R6KRF36:/etc/profile.d$ ls -l
total 32
-rw-r--r-- 1 root root 96 Aug 20 2018 01-locale-fix.sh
-rw-r--r-- 1 root root 1557 Dec 4 2017 Z97-byobu.sh
-rwxr-xr-x 1 root root 3417 Mar 11 22:07 Z99-cloud-locale-test.sh
-rwxr-xr-x 1 root root 873 Mar 11 22:07 Z99-cloudinit-warnings.sh
-rw-r--r-- 1 root root 825 Mar 21 10:55 apps-bin-path.sh
-rw-r--r-- 1 root root 664 Apr 2 2018 bash_completion.sh
-rw-r--r-- 1 root root 1003 Dec 29 2015 cedilla-portuguese.sh
-rw-r--r-- 1 root root 2207 Aug 27 12:25 oraclejdk.sh …Run Code Online (Sandbox Code Playgroud) permissions executable shell-script windows-subsystem-for-linux
bash ×3
shell-script ×3
shell ×2
conventions ×1
executable ×1
libraries ×1
linux ×1
login ×1
permissions ×1
rm ×1
source ×1
ubuntu ×1
variable ×1