Last active
December 21, 2015 06:59
-
-
Save knjname/6268414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# bash executes this incorrectly. | |
# On the other hand zsh executes this correctly. | |
# Because bash spawns a sub-shell inside while-do loop meanwhile zsh doesn't it. | |
declare -i sum | |
seq 0 10 | while read num ; do | |
let sum+=$num | |
done | |
# bash => nothing | |
# zsh => 55 | |
echo $sum | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment