Quote:
Originally Posted by
Perderabo
This is quite a mess. I don't see an easy way to fix it. I think a complete redesign is in order. The crux of your problem is code like:
player1hand=`deal_hole`
The shell must launch a sub-shell to process the `deal_hole` part. Within this subshell you mark some cards as being delt. Then the subshell exits and the main shell does know which cards were delt. You can't write a function that modifies global data and then invoke it in a subshell.
Good info Perderabo...
What would you suggest to keep things in order? Could I put the entire "play" code (meaning the part that is dealing and whatnot) into a single function?
I am not really strong with arrays, but if you could point me in the right direction I can probably figure it out.
Edit: Putting the play section to a function did not work, but I now see what you are talking about with the $player1hand issue spawning a subshell. What's a better way to save the player's hands so they can be referenced at the end of the script?
Edit2: Not assigning the output of the function (such as deal_hole) to a variable solves the problem, but I would like a way to reference the output later... is it possible?
Edit3: Ok, here's an idea... I'm having trouble finding if this is possible, but could I run the 'deal_hole' function and have the output send to stdout and then also redirected to a file that could be called later?