Prevent error messages while detecting OS (#40)

* add test for file existence to avoid errors
This commit is contained in:
Michael Bryant 2020-10-23 15:07:41 -07:00 committed by GitHub
parent b0982441aa
commit f6cf2770e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,10 @@ function _tide_detect_os
end end
function _tide_detect_os_linux_cases -a file key function _tide_detect_os_linux_cases -a file key
if not test -f $file
return 1
end
set -l splitOsRelease (cat $file | string split '=') set -l splitOsRelease (cat $file | string split '=')
set -l value $splitOsRelease[(math (contains --index $key $splitOsRelease)+1)] set -l value $splitOsRelease[(math (contains --index $key $splitOsRelease)+1)]
set -l name (string trim --chars='"' $value | string lower) set -l name (string trim --chars='"' $value | string lower)