|
@@ -0,0 +1,59 @@
|
|
|
+#!/bin/bash
|
|
|
+# Existence of arg
|
|
|
+echo "[exist] Testing existence."
|
|
|
+if [ -n $1 ]
|
|
|
+then
|
|
|
+ echo 'Arg 1 exists'
|
|
|
+fi
|
|
|
+
|
|
|
+if [ -z $1 ]
|
|
|
+then
|
|
|
+ echo 'Arg 1 does not exist'
|
|
|
+fi
|
|
|
+
|
|
|
+# Existence of prompt
|
|
|
+read -p 'Type > ' var
|
|
|
+if [ -n $var ]
|
|
|
+then
|
|
|
+ echo 'Var exists'
|
|
|
+fi
|
|
|
+
|
|
|
+if [ -z $var ]
|
|
|
+then
|
|
|
+ echo 'Var does not exist'
|
|
|
+fi
|
|
|
+
|
|
|
+# Existance of nothing
|
|
|
+if [ -n $not_declared_variable ]
|
|
|
+then
|
|
|
+ echo 'not_declared_variable exists'
|
|
|
+fi
|
|
|
+
|
|
|
+if [ -z $not_declared_variable ]
|
|
|
+then
|
|
|
+ echo 'not_declared_variable does not exist'
|
|
|
+fi
|
|
|
+
|
|
|
+# Existance of quoted nothing
|
|
|
+if [ -n "$not_declared_quoted_variable" ]
|
|
|
+then
|
|
|
+ echo 'not_declared_quoted_variable exists'
|
|
|
+fi
|
|
|
+
|
|
|
+if [ -z "$not_declared_quoted_variable" ]
|
|
|
+then
|
|
|
+ echo 'not_declared_quoted_variable does not exist'
|
|
|
+fi
|
|
|
+
|
|
|
+# Existance of void
|
|
|
+if [ -n ]
|
|
|
+then
|
|
|
+ echo 'void exists'
|
|
|
+fi
|
|
|
+
|
|
|
+if [ -z ]
|
|
|
+then
|
|
|
+ echo 'void does not exist'
|
|
|
+fi
|
|
|
+
|
|
|
+echo '[exist] End of script.'
|