| 1 | #!/bin/bash |
| 2 | |
| 3 | var1=unset |
| 4 | previous=$var1 |
| 5 | |
| 6 | while echo "previous-variable = $previous" |
| 7 | echo |
| 8 | previous=$var1 |
| 9 | [ "$var1" != end ] # Keeps track of what $var1 was previously. |
| 10 | # Four conditions on *while*, but only the final one controls loop. |
| 11 | # The *last* exit status is the one that counts. |
| 12 | do |
| 13 | echo "Input variable #1 (end to exit) " |
| 14 | read var1 |
| 15 | echo "variable #1 = $var1" |
| 16 | done |
| 17 | |
| 18 | # Try to figure out how this all works. |
| 19 | # It's a wee bit tricky. |
| 20 | |
| 21 | exit 0 |