What is causing my custom zsh script terminal command to hang?

I've created a custom zsh script for taking notes about my day and keeping track of time so I can fill out time sheets easier. It works fine most of the time but every now and again just hangs. It logs to the txt file even when it hangs but it doesn't execute the "say" command.

I think it's a problem with how I'm selecting the random string but I don't know enough about zsh to fix it.

I'm using zsh and this is in my .zshrc file.

createLog() { LOGFILE=$HOME/Google\ Drive/autosdls.txt # chmod 755 $LOGFILE LASTLINE="$(tail -1 $LOGFILE)" LASTTIME="$(grep -oE "[[:digit:]]{10}" <<<"$LASTLINE")" TIME="$(date +%s)" TIMESPENT=$((($TIME-$LASTTIME)/60)) echo "$TIMESPENT" echo "[ ] $TIMESPENT Minutes : $1 |$(date +%s)|" >> $LOGFILE 2>&1 # Seed random generator RANDOM=$$$(date +%s) encouragements=("Greatjob!" "Thank you." "Productivity Node Assimilated" "Well done. Your ambition is matched only by your zeal" "Engage" "You're the best! Around! Nothing's gonna ever keep you down.") selectedexpression=${encouragements[($RANDOM % ${#encouragements[@]})-1]} say $selectedexpression # echo $selectedexpression } alias sdlog=createLog

Category:arrays Views:1 Time:2018-06-11

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.147 (s). 11 q(s)