| 1 | #!/bin/bash |
| 2 | # lastpipe-option.sh |
| 3 | |
| 4 | line='' # Null value. |
| 5 | echo "\$line = "$line"" # $line = |
| 6 | |
| 7 | echo |
| 8 | |
| 9 | shopt -s lastpipe # Error on Bash version -lt 4.2. |
| 10 | echo "Exit status of attempting to set \"lastpipe\" option is $?" |
| 11 | # 1 if Bash version -lt 4.2, 0 otherwise. |
| 12 | |
| 13 | echo |
| 14 | |
| 15 | head -1 $0 | read line # Pipe the first line of the script to read. |
| 16 | # ^^^^^^^^^ Not in a subshell!!! |
| 17 | |
| 18 | echo "\$line = "$line"" |
| 19 | # Older Bash releases $line = |
| 20 | # Bash version 4.2 $line = #!/bin/bash |