We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
0 parents commit 2b41b97Copy full SHA for 2b41b97
README.md
@@ -0,0 +1,20 @@
1
+# bash-types
2
+
3
+Types for bash.
4
5
+Is it safe? No.
6
+Is it fast? No.
7
+Is it stable? No.
8
+Is it smart? No.
9
10
+Does it work? ... kinda actually
11
12
+```bash
13
+source bash-types.sh
14
15
+int a=2
16
17
+echo "$a" # => 2
18
19
+int b=foo # => Error: int b assigned to non numeric value 'foo'
20
+```
bash-types.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+int() {
+ local var="$1"
+ local val
+ eval "$*"
+ var="${var%%=*}"
+ val="$(eval "echo \$$var")"
+ if [[ "$val" =~ ^[0-9]+$ ]]
+ then
+ return
+ fi
+ echo "Error: int $var assigned to non numeric value '$val'"
+ exit 1
+}
21
22
0 commit comments