@@ -3600,7 +3600,7 @@ \subsection{Reading variables}
36003600 echo " for multiplication or quotient for quotient."
36013601 exit 1 # End up with an error
36023602 }
3603- if [ "$#" -ne "3" ]; then # Do we have 3 parameters provided?
3603+ if [[ "$#" -ne "3" ] ]; then # Do we have 3 parameters provided?
36043604 echo "Error! Requiring 3 parameters! Received $# ($*)."
36053605 usagehelp # The function to print help
36063606 fi # "=~" means testing if $ 1 fits to regular expression in $ NUMBER
@@ -3683,8 +3683,8 @@ \subsection{Reading variables}
36833683 ;; # End of this option
36843684 a) # Parameter "-a" accepts some value (e.g. "-a X" for number)
36853685 # Check if provided value makes sense (integer between 10 and 300 )
3686- if [[ "$ OPTARG" =~ ^[0-9]+$ ]] && [ "$ OPTARG" -ge 10 ] &&
3687- [ "$OPTARG" -le 300 ]; then # The condition is long...
3686+ if [[ "$ OPTARG" =~ ^[0-9]+$ ]] && [[ "$ OPTARG" -ge 10 ] ] &&
3687+ [[ "$OPTARG" -le 300 ] ]; then # The condition is long...
36883688 VALUE=$ OPTARG # $ OPTARG always contains value of parameter
36893689 echo "Value is OK: $VALUE"
36903690 else
@@ -3708,7 +3708,7 @@ \subsection{Reading variables}
37083708 esac
37093709 done # ...the end.
37103710 # Check if all required values are provided
3711- if [ -z "$ INPUTFILE" ] || [ -z "$OUTPUTFILE" ]; then
3711+ if [[ -z "$ INPUTFILE" ]] || [[ -z "$OUTPUTFILE" ] ]; then
37123712 echo "Error! Name of input and/or output file was not provided!"
37133713 echo "See \" $ 0 -h\" for help usage..."
37143714 exit 1
@@ -3720,7 +3720,7 @@ \subsection{Reading variables}
37203720\begin {frame}[fragile]{Multiple switches in classical UNIX form (no positional) IV}
37213721 \begin {bashcode}
37223722 # ...continuing from previous slide...
3723- if [ -z "$ VALUE" ]; then
3723+ if [[ -z "$ VALUE" ] ]; then
37243724 echo "Warning! Value for \" -a\" was not provided! Using default (10)."
37253725 VALUE=10
37263726 fi
@@ -3764,12 +3764,12 @@ \subsection{Reading variables}
37643764 \begin {bashcode }
37653765 #!/bin/bash
37663766 # We expect exactly one parameter
3767- if [ "$#" -ne "1" ]; then
3767+ if [[ "$#" -ne "1" ] ]; then
37683768 echo "Error! Exactly one parameter is required!"
37693769 exit 1
37703770 fi
37713771 # Verify that file exists and is readable
3772- if [ ! -r "$1" ]; then
3772+ if [[ ! -r "$1" ] ]; then
37733773 echo "Error! The file provided does not exist or is not readable!"
37743774 exit 1
37753775 fi
0 commit comments