start using shellcheck

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2019-04-01 18:24:05 +02:00
parent da5e96d49e
commit 614eae85c7
5 changed files with 25 additions and 18 deletions

View File

@ -1,7 +1,10 @@
#!/bin/sh
# description: Start or stop telegram-bash-bot
#
#### $$VERSION$$ v0.5-rc-4-g92e9e9c
#### $$VERSION$$ v0.6-dev-2-gda5e96d
# shellcheck disable=SC2009
# shellcheck disable=SC2181
#
### BEGIN INIT INFO
# Provides: bashbot

View File

@ -4,7 +4,10 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.5-rc-3-gf67503c
#### $$VERSION$$ v0.6-dev-2-gda5e96d
#
# shellcheck disable=SC2154
# shellcheck disable=SC2034
# adjust your language setting here, e.g.when run from other user or cron.
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
@ -26,11 +29,11 @@ if [ "$1" = "source" ];then
else
if ! tmux ls | grep -v send | grep -q "$copname"; then
[ ! -z "${URLS[*]}" ] && {
curl -s ${URLS[*]} -o $NAME
curl -s "${URLS[*]}" -o "$NAME"
send_file "${CHAT[ID]}" "$NAME" "$CAPTION"
rm -f "$NAME"
}
[ ! -z ${LOCATION[*]} ] && send_location "${CHAT[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}"
[ ! -z "${LOCATION[*]}" ] && send_location "${CHAT[ID]}" "${LOCATION[LATITUDE]}" "${LOCATION[LONGITUDE]}"
# Inline
if [ $INLINE == 1 ]; then
@ -61,7 +64,7 @@ else
case "$MESSAGE" in
'/question')
checkproc
if [ $res -gt 0 ] ; then
if [ "$res" -gt 0 ] ; then
startproc "./question"
else
send_normal_message "${CHAT[ID]}" "$MESSAGE already running ..."
@ -70,7 +73,7 @@ else
'/run-notify')
myback="notify"; checkback "$myback"
if [ $res -gt 0 ] ; then
if [ "$res" -gt 0 ] ; then
background "./notify 60" "$myback" # notify every 60 seconds
else
send_normal_message "${CHAT[ID]}" "Background command $myback already running ..."
@ -78,7 +81,7 @@ else
;;
'/stop-notify')
myback="notify"; checkback "$myback"
if [ $res -eq 0 ] ; then
if [ "$res" -eq 0 ] ; then
killback "$myback"
send_normal_message "${CHAT[ID]}" "Background command $myback canceled."
else
@ -120,10 +123,10 @@ Get the code in my [GitHub](http://github.com/topkecleon/telegram-bot-bash)
'/cancel')
checkprog
if [ $res -eq 0 ] ; then killproc && send_message "${CHAT[ID]}" "Command canceled.";else send_message "${CHAT[ID]}" "No command is currently running.";fi
if [ "$res" -eq 0 ] ; then killproc && send_message "${CHAT[ID]}" "Command canceled.";else send_message "${CHAT[ID]}" "No command is currently running.";fi
;;
*)
if tmux ls | grep -v send | grep -q $copname;then inproc; else send_message "${CHAT[ID]}" "$MESSAGE" "safe";fi
if tmux ls | grep -v send | grep -q "$copname";then inproc; else send_message "${CHAT[ID]}" "$MESSAGE" "safe";fi
;;
esac
fi

2
notify
View File

@ -2,7 +2,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.5-rc-3-gf67503c
#### $$VERSION$$ v0.6-dev-2-gda5e96d
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment

View File

@ -3,7 +3,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#### $$VERSION$$ v0.5-rc-3-gf67503c
#### $$VERSION$$ v0.6-dev-2-gda5e96d
# adjust your language setting here
# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment
@ -16,11 +16,11 @@ unset IFS
echo "Why hello there.
Would you like some tea (y/n)?"
read answer
read -r answer
[[ $answer =~ ^([yY][eE][sS]|[yY])$ ]] && echo "OK then, here you go: http://www.rivertea.com/blog/wp-content/uploads/2013/12/Green-Tea.jpg" || echo "OK then."
until [ "$SUCCESS" = "y" ] ;do
echo 'Do you like Music? mykeyboardstartshere "Yass!" "No"'
read answer
read -r answer
case $answer in
'Yass!') echo "Goody! mykeyboardendshere";SUCCESS=y;;
'No') echo "Well that's weird. mykeyboardendshere";SUCCESS=y;;

11
version
View File

@ -1,6 +1,7 @@
#!/bin/sh
#!/bin/bash
#
#### $$VERSION$$ v0.5-rc-3-gf67503c
#### $$VERSION$$ v0.6-dev-2-gda5e96d
# shellcheck disable=SC2016
#
# Easy Versioning in git:
#
@ -36,15 +37,15 @@
unset IFS
# set -f # if you are paranoid use set -f to disable globbing
VERSION="`git describe --tags --long`"
VERSION="$(git describe --tags --long)"
echo "Update files to version $VERSION ..."
for file in `ls`
for file in *
do
[ ! -f "$file" ] && continue
#[ "$file" == "version" ] && continue
echo -n " $file"
sed -i 's/^#### $$VERSION$$.*/#### \$\$VERSION\$\$ '$VERSION'/' $file
sed -i 's/^#### $$VERSION$$.*/#### \$\$VERSION\$\$ '"$VERSION"'/' "$file"
done
echo " done."