Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- x=0
- testfunc () {
- x=$[x+1]
- echo "testfunc: x=$x"
- }
- testfunc
- testfunc
- testfunc
- echo "main/global: x=$x"
- # Output:
- #
- # [pts/14][user@phobos]:/tmp$ ./test.sh
- # testfunc: x=1
- # testfunc: x=2
- # testfunc: x=3
- # main: x=3
- # [pts/14][user@phobos]:/tmp$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement