hangover: lint the shell

* arrays are bash-only features
* `$[]` is crazy outdated
* `[ -gt ]` is boring when you have the straight arithmetic operator stuff
This commit is contained in:
Mingye Wang 2020-03-09 16:04:39 +08:00 committed by GitHub
parent 9cb4a2e49d
commit ea12a398d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
#!/bin/sh -e
#!/bin/bash -e
# Exit early if any session with my username is found
if who | grep -wq $USER; then
if who | grep -wq "^$USER"; then
exit
fi
@ -15,18 +15,19 @@ EXCUSES=(
'Food poisoning'
'Not feeling well'
)
rand=$[ $RANDOM % ${#EXCUSES[@]} ]
rand=$(( RANDOM % ${#EXCUSES[@]} ))
RANDOM_EXCUSE=${EXCUSES[$rand]}
MESSAGE="Gonna work from home. "$RANDOM_EXCUSE
# Send a text message
RESPONSE=`curl -fSs -u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \
RESPONSE=$(curl -fSs -u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \
-d "From=$MY_NUMBER" -d "To=$NUMBER_OF_BOSS" -d "Body=$MESSAGE" \
"https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages"`
"https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages")
# Log errors
if [ $? -gt 0 ]; then
if (( $? > 0 )); then
echo "Failed to send SMS: $RESPONSE"
exit 1
fi