I am trying to catch typeset error by the below shell script test.sh:
Shell Script
typeset -i int
int=2
echo $int
int=asd || echo "type mismatch"
But i am getting output as:
Output
./test.sh
2
./test.sh[4]: asd: bad number
Required Result
./test.sh
2
./test.sh[4]: asd: bad number
**type mismatch**
I am using the following machine:
bash --version
GNU bash, version 3.2.51(1)-release (sparc-sun-solaris2.10)
Copyright (C) 2007 Free Software Foundation, Inc.
Please suggest me the change i need to make in my script. I need a way to make sure that the input parameter is INT. And i have to use typeset along with Exception Handling.