Recover a running script from a terminal session

look for the script's pid using ps

ps -ef|grep script.sh
Fdo  8983  8463  0 12:28 pts/2    00:00:00 /bin/bash ./script.sh

check /proc/$PID/fd/; there should be a broken link to the script file, but cat should work (while the script is running!):

cat /proc/8983/fd/255 
#!/bin/bash
# script contents!

good luck!