Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- at the end, this code echos "JKC: -><-", so $last_scrub is empty. why?
- echo $scrub_list | while read scrub_entry; do
- scrub_date=$(echo $scrub_entry | awk '{print $1}')
- # was this scrub history entry a scrub -s?
- is_stop=0
- echo $scrub_entry | egrep -q " *-s *"
- if [ "$?" = "0" ]; then
- echo "found scrub -s: $scrub_entry"
- is_stop=1
- else
- echo "found scrub: $scrub_entry"
- fi
- # if 1st time (e.g. $last_scrub is empty), then set
- # last_scrub and continue
- if [ -z $last_scrub ]; then
- if [ "$is_stop" = "0" ]; then
- echo "INIT(last_scrub) = $scrub_date"
- last_scrub=$scrub_date
- fi
- # else: if the first entry is a scrub -s (would this ever happen?) just continue
- continue
- else
- echo "last_scrub was previously set to: $scrub_date"
- # last_scrub was already set.
- # check if scrub -s, in which case we set the last scrub to the previous
- if [ "$is_stop" = "1" ]; then
- echo "THIS is a scrub -s"
- if [ -z $second_to_last_scrub ]; then
- # no prior successful scrub
- echo "NO PREVIOUS SUCCESSFUL SCRUB, BLANK IT"
- last_scrub=""
- else
- echo "REUSE PREVIOUS SUCCESSFUL SCRUB: $second_to_last_scrub"
- last_scrub=$second_to_last_scrub
- fi
- else
- echo "NORMAL SCRUB, UPDATE second_to_last_scrub=$last_scrub and last_scrub=$scrub_date"
- # regular scrub, update last and second_to_last
- second_to_last_scrub=$last_scrub
- last_scrub=$scrub_date
- fi
- fi
- done
- echo "JKC: ->$last_scrub<-"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement