Page MenuHomec4science

tools.sh
No OneTemporary

File Metadata

Created
Tue, May 7, 12:58

tools.sh

#!/bin/bash
function get_file_encoding() {
local filename=$1
local output=$(file --brief $filename)
case $output in
*ASCII*)
echo "unicode"
return 0;;
*UTF-8*)
echo "unicode"
return 0;;
*8859*)
echo "iso"
return 0;;
"*")
echo "unknown";;
esac
return 1
}
function function_exists() {
if [ $(type "$1" 2>&1 | grep -c "$1"' is a function') -eq 1 ]; then
return 0
else
return 1
fi
}
function check_OS() {
OS=$(uname | tr "[A-Z]" "[a-z]")
if [ "$OS" == "linux" ]; then return 0; fi
OS="unknown"
return 1
}
function check_OS_subtype() {
OS_SUBTYPE="unknown"
if [ -r /etc/gentoo-release ]; then OS_SUBTYPE="gentoo"; return 0; fi
return 1
}
function check_AMC_version() {
AMC_VERSION="unknown"
which auto-multiple-choice > /dev/null 2>&1
if [ $? -gt 0 ]; then
AMC_VERSION="none"
return 1
fi
case $OS in
"linux")
case $OS_SUBTYPE in
"gentoo")
AMC_VERSION=$(eix --xml auto-multiple-choice | grep 'installed="1"' | tr " " "\n" | grep '^id' | cut -d '"' -f 2)
return 0;;
esac
esac
return 1
}
# EOF

Event Timeline