Last active
August 29, 2015 13:56
-
-
Save dermoth/9337183 to your computer and use it in GitHub Desktop.
Bash (()) and error handling
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
[thomas_guyot@localhost ~]$ bash --version | |
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu) | |
Copyright (C) 2005 Free Software Foundation, Inc. | |
[thomas_guyot@localhost ~]$ trap 'echo Argh' ERR | |
[thomas_guyot@localhost ~]$ variable=0 | |
[thomas_guyot@localhost ~]$ ((variable++)) | |
[thomas_guyot@localhost ~]$ echo $? | |
1 | |
[thomas_guyot@localhost ~]$ echo $variable | |
1 | |
[root@localhost ~]# bash --version | |
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) | |
Copyright (C) 2009 Free Software Foundation, Inc. | |
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | |
This is free software; you are free to change and redistribute it. | |
There is NO WARRANTY, to the extent permitted by law. | |
[root@localhost ~]# trap 'echo Argh' ERR | |
[root@localhost ~]# variable=0 | |
[root@localhost ~]# ((variable++)) | |
Argh | |
[root@localhost ~]# echo $? | |
1 | |
[root@localhost ~]# echo $variable | |
1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment