git.slaskete.net
/
einar-bin
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
10f3be9
)
Fix minor complaints from shellcheck
author
Einar Jørgen Haraldseid
<einar@haraldseid.net>
Sat, 16 Feb 2019 08:47:20 +0000
(09:47 +0100)
committer
Einar Jørgen Haraldseid
<einar@haraldseid.net>
Sat, 16 Feb 2019 08:47:20 +0000
(09:47 +0100)
imgurgame.bash
patch
|
blob
|
history
diff --git
a/imgurgame.bash
b/imgurgame.bash
index 88af62077db5e9cb981aa236deb9045c08f8e85f..ef098412d8497224838be38ba1f697a814d7d67d 100755
(executable)
--- a/
imgurgame.bash
+++ b/
imgurgame.bash
@@
-7,14
+7,16
@@
readonly BROWSER="google-chrome"
imgururl() {
# 1/3 chance for length of 5, 6 or 7 length string
STRLN=$((5 + ${RANDOM} % 3))
imgururl() {
# 1/3 chance for length of 5, 6 or 7 length string
STRLN=$((5 + ${RANDOM} % 3))
- local ID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${STRLN} | head -n 1)
+ local ID
+ ID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${STRLN} | head -n 1)
echo "http://i.imgur.com/${ID}.jpg"
}
# Test if we found a valid URL
testimgur() {
local URL=${1}
echo "http://i.imgur.com/${ID}.jpg"
}
# Test if we found a valid URL
testimgur() {
local URL=${1}
- local RESULT=$(curl -s -o /dev/null -I -w "%{http_code}" ${URL})
+ local RESULT
+ RESULT=$(curl -s -o /dev/null -I -w "%{http_code}" ${URL})
if [[ ${RESULT} == "200" ]]; then
echo true
else
if [[ ${RESULT} == "200" ]]; then
echo true
else
@@
-25,7
+27,8
@@
testimgur() {
main() {
local FAIL=0
while true; do
main() {
local FAIL=0
while true; do
- local URL=$(imgururl)
+ local URL
+ URL=$(imgururl)
if [[ $(testimgur ${URL}) == "true" ]]; then
echo "Found ${URL} after ${FAIL} failed tries"
${BROWSER} ${URL} > /dev/null 2>&1
if [[ $(testimgur ${URL}) == "true" ]]; then
echo "Found ${URL} after ${FAIL} failed tries"
${BROWSER} ${URL} > /dev/null 2>&1