Skip to content

Instantly share code, notes, and snippets.

@knjname
Last active December 21, 2015 06:59
Show Gist options
  • Save knjname/6268414 to your computer and use it in GitHub Desktop.
Save knjname/6268414 to your computer and use it in GitHub Desktop.
#!/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