plugins/base: use `$OSTYPE` instead of `$(uname)`
Alsö, use `[[` instead of `[` as the former has less insane argument handling being shell syntax rather than a builtin command that must emulate being a real binarypull/1911/head
parent
dbba78f210
commit
0c6e88402c
|
|
@ -33,7 +33,7 @@ function myip ()
|
||||||
for url in ${list[*]}
|
for url in ${list[*]}
|
||||||
do
|
do
|
||||||
res=$(curl -fs "${url}")
|
res=$(curl -fs "${url}")
|
||||||
if [ $? -eq 0 ];then
|
if [[ $? -eq 0 ]];then
|
||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
@ -48,7 +48,7 @@ function pickfrom ()
|
||||||
example '$ pickfrom /usr/share/dict/words'
|
example '$ pickfrom /usr/share/dict/words'
|
||||||
group 'base'
|
group 'base'
|
||||||
local file=$1
|
local file=$1
|
||||||
[ -z "$file" ] && reference $FUNCNAME && return
|
[[ -z "$file" ]] && reference $FUNCNAME && return
|
||||||
length=$(cat $file | wc -l)
|
length=$(cat $file | wc -l)
|
||||||
n=$(expr $RANDOM \* $length \/ 32768 + 1)
|
n=$(expr $RANDOM \* $length \/ 32768 + 1)
|
||||||
head -n $n $file | tail -1
|
head -n $n $file | tail -1
|
||||||
|
|
@ -70,7 +70,7 @@ function passgen ()
|
||||||
|
|
||||||
# Create alias pass to passgen when pass isn't installed or
|
# Create alias pass to passgen when pass isn't installed or
|
||||||
# BASH_IT_LEGACY_PASS is true.
|
# BASH_IT_LEGACY_PASS is true.
|
||||||
if ! command -v pass &>/dev/null || [ "$BASH_IT_LEGACY_PASS" = true ]
|
if ! command -v pass &>/dev/null || [[ "$BASH_IT_LEGACY_PASS" = true ]]
|
||||||
then
|
then
|
||||||
alias pass=passgen
|
alias pass=passgen
|
||||||
fi
|
fi
|
||||||
|
|
@ -129,15 +129,15 @@ function usage ()
|
||||||
about 'disk usage per directory, in Mac OS X and Linux'
|
about 'disk usage per directory, in Mac OS X and Linux'
|
||||||
param '1: directory name'
|
param '1: directory name'
|
||||||
group 'base'
|
group 'base'
|
||||||
if [ $(uname) = "Darwin" ]; then
|
if [[ "$OSTYPE" == 'darwin'* ]]; then
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
du -hd 1 "$1"
|
du -hd 1 "$1"
|
||||||
else
|
else
|
||||||
du -hd 1
|
du -hd 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [ $(uname) = "Linux" ]; then
|
elif [[ "$OSTYPE" = 'linux'* ]]; then
|
||||||
if [ -n "$1" ]; then
|
if [[ -n "$1" ]]; then
|
||||||
du -h --max-depth=1 "$1"
|
du -h --max-depth=1 "$1"
|
||||||
else
|
else
|
||||||
du -h --max-depth=1
|
du -h --max-depth=1
|
||||||
|
|
@ -145,7 +145,8 @@ function usage ()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -e "${BASH_IT}/plugins/enabled/todo.plugin.bash" ] && [ ! -e "${BASH_IT}/plugins/enabled/*${BASH_IT_LOAD_PRIORITY_SEPARATOR}todo.plugin.bash" ]; then
|
if [[ ! -e "${BASH_IT}/plugins/enabled/todo.plugin.bash" ]] && [[ ! -e "${BASH_IT}/plugins/enabled/*${BASH_IT_LOAD_PRIORITY_SEPARATOR}todo.plugin.bash" ]]
|
||||||
|
then
|
||||||
# if user has installed todo plugin, skip this...
|
# if user has installed todo plugin, skip this...
|
||||||
function t ()
|
function t ()
|
||||||
{
|
{
|
||||||
|
|
@ -180,11 +181,11 @@ mkiso ()
|
||||||
group 'base'
|
group 'base'
|
||||||
|
|
||||||
if type "mkisofs" > /dev/null; then
|
if type "mkisofs" > /dev/null; then
|
||||||
[ -z ${1+x} ] && local isoname=${PWD##*/} || local isoname=$1
|
[[ -z ${1+x} ]] && local isoname=${PWD##*/} || local isoname=$1
|
||||||
[ -z ${2+x} ] && local destpath=../ || local destpath=$2
|
[[ -z ${2+x} ]] && local destpath=../ || local destpath=$2
|
||||||
[ -z ${3+x} ] && local srcpath=${PWD} || local srcpath=$3
|
[[ -z ${3+x} ]] && local srcpath=${PWD} || local srcpath=$3
|
||||||
|
|
||||||
if [ ! -f "${destpath}${isoname}.iso" ]; then
|
if [[ ! -f "${destpath}${isoname}.iso" ]]; then
|
||||||
echo "writing ${isoname}.iso to ${destpath} from ${srcpath}"
|
echo "writing ${isoname}.iso to ${destpath} from ${srcpath}"
|
||||||
mkisofs -V ${isoname} -iso-level 3 -r -o "${destpath}${isoname}.iso" "${srcpath}"
|
mkisofs -V ${isoname} -iso-level 3 -r -o "${destpath}${isoname}.iso" "${srcpath}"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue