macOS fix

macOS’s BSD readlink is different from GNU readlink, says: illegal option -- f
This commit is contained in:
Z. Eilen
2018-12-04 21:34:53 +01:00
committed by GitHub
parent a563174735
commit ae20cdcf04

View File

@@ -1795,14 +1795,14 @@ detectshell_ver () {
detectshell () {
if [[ ! "${shell_type}" ]]; then
if [[ "${distro}" == "Cygwin" || "${distro}" == "Msys" || "${distro}" == "Haiku" || "${distro}" == "Alpine Linux" ||
"${distro}" == "TinyCore" || "${distro}" == "Raspbian" || "${OSTYPE}" == "gnu" ]]; then
"${distro}" == "Mac OS X" || "${distro}" == "TinyCore" || "${distro}" == "Raspbian" || "${OSTYPE}" == "gnu" ]]; then
shell_type=$(echo "$SHELL" | awk -F'/' '{print $NF}')
elif readlink -f "$SHELL" 2>&1 | grep -q -i 'busybox'; then
shell_type="BusyBox"
else
if [[ "${OSTYPE}" =~ "linux" ]]; then
shell_type=$(tr '\0' '\n' </proc/$PPID/cmdline | head -1)
elif [[ "${distro}" == "Mac OS X" || "${distro}" =~ "BSD" ]]; then
elif [[ "${distro}" =~ "BSD" ]]; then
shell_type=$(ps -p $PPID -o command | tail -1)
else
shell_type=$(ps -p "$(ps -p $PPID | awk '$1 !~ /PID/ {print $1}')" | awk 'FNR>1 {print $1}')