bash - Bash 源命令不适用于“curl”
问题描述
我正在尝试source
与curl
.
但是,当我在我的机器(Mac OS 10.13.4)上运行以下代码段时,它会输出以下错误:read_os_name: command not found
.
read_os_name.sh
:
#!/bin/bash
declare -r UTILS_URL="https://raw.githubusercontent.com/nicholasadamou/bash-utils/master/utils.sh"
source <(curl -s "$UTILS_URL")
read_os_name #Should output "macos"
read_os_name()
来自utils.sh
:
read_os_name() {
local kernelName=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
kernelName="$(uname -s)"
if [ "$kernelName" == "Darwin" ]; then
printf "macos"
elif [ "$kernelName" == "Linux" ] && [ -e "/etc/os-release" ] || [ -e "/usr/lib/os-release" ]; then
local conf=""
if test -r /etc/os-release ; then
conf="/etc/os-release"
else
conf="/usr/lib/os-release"
fi
awk -F= '$1=="ID" { print $2 ;}' "$conf" | sed -e 's/^"//' -e 's/"$//'
fi
}
解决方案
推荐阅读
- javascript - 使用 javascript 访问文件系统
- python - 另一列中每次出现的一列的总和值
- git - 本地中央存储库出现问题,从另一个本地位置拉取和推送更改
- c# - 如何从背后的 DNN 皮肤代码访问 asp.net 控件
- terminal - Pycharm 终端不使用 venv
- mysql - Mysql性能问题:插入10000条记录超时,创建5000条记录仍然需要26秒
- microsoft-edge - 超越 Microsoft Edge 大声朗读速度限制
- vb.net - 阻止 DataGridView BindingSource 更新特定列的单元格值
- php - 未捕获的错误:不能使用 stdClass 类型的对象作为数组
- python - 对象没有“附加”属性?