Skip to content

Instantly share code, notes, and snippets.

@wilt00
Created October 14, 2017 03:18
Show Gist options
  • Save wilt00/7477b68a491f6d9b025d3acc951285fe to your computer and use it in GitHub Desktop.
Save wilt00/7477b68a491f6d9b025d3acc951285fe to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Usage:
# ./yistep.sh [filename.yo]
# IMPORTANT!!
# In order to work properly, this script needs to be in the same directory
# as your yis executable
# ---
# Run ./yis command with the first argument this script was run with ($1)
# Pipe that output to the head command, which deletes all but the first line
# At this point, we are expecting the value to be "Stopped in XX steps ..."
# Pipe that output to awk, which selects the 3rd space-separated word of the line
# Store that output in the variable Max
Max=`./yis $1 | head -n 1 | awk -F ' ' '{ print $3 }'`
# $Max now stores the total number of steps required to run program to completion
# Use the GNU seq command to generate a sequence of numbers from 1 to $Max
# Make sure your computer has this command available by running "which seq" at the terminal
for i in $(seq "$Max");
do
# Run ./yis with the original first argument of this script and the current value of $i
./yis $1 $i
# Read a single character (-n1) from the user, and store it in the value $key
read -n1 -r -p "Press any key to continue, or q to quit" key
# Print a newline, since we might not have gotten one from the user just now
printf '\n'
# Quit if key pressed was 'q'
if [ "$key" = "q" ]; then
exit
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment