I am trying to use source
in-conjunction with curl
.
However, when I run the following segment of code on my machine (Mac OS 10.13.4) it outputs the following error: 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()
from 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
}