You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
4 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
|
CALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/Calls/"
|
||
|
SMS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/SMS/"
|
||
|
|
||
|
die(){
|
||
|
echo "$@" > /dev/stderr
|
||
|
rm "$FILE"
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
trimWhitespace(){
|
||
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
|
||
|
}
|
||
|
|
||
|
deleteEmptyLines(){
|
||
|
sed '/^$/ d'
|
||
|
}
|
||
|
|
||
|
# Iterate over options breaking -ab into -a -b when needed and --foo=bar into
|
||
|
# --foo bar
|
||
|
optstring=h
|
||
|
unset options
|
||
|
while (($#)); do
|
||
|
case $1 in
|
||
|
# If option is of type -ab
|
||
|
-[!-]?*)
|
||
|
# Loop over each character starting with the second
|
||
|
for ((i=1; i < ${#1}; i++)); do
|
||
|
c=${1:i:1}
|
||
|
|
||
|
# Add current char to options
|
||
|
options+=("-$c")
|
||
|
|
||
|
# If option takes a required argument, and it's not the last char make
|
||
|
# the rest of the string its argument
|
||
|
if [[ $optstring = *"$c:"* && ${1:i+1} ]]; then
|
||
|
options+=("${1:i+1}")
|
||
|
break
|
||
|
fi
|
||
|
done
|
||
|
;;
|
||
|
|
||
|
# If option is of type --foo=bar
|
||
|
--?*=*) options+=("${1%%=*}" "${1#*=}") ;;
|
||
|
# add --endopts for --
|
||
|
--) options+=(--endopts) ;;
|
||
|
# Otherwise, nothing special
|
||
|
*) options+=("$1") ;;
|
||
|
esac
|
||
|
shift
|
||
|
done
|
||
|
set -- "${options[@]}"
|
||
|
unset options
|