Skip to content

Commit bcdba76

Browse files
committed
Small updates of scripts based on ShellCheck advice.
1 parent 2e81249 commit bcdba76

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

presentation/linux_bash_metacentrum_course.tex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

scripts_data/interactive4.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function usagehelp {
1212
}
1313

1414
# Do we have 3 parameters provided?
15-
if [ "$#" -ne "3" ]; then
15+
if [[ "$#" -ne "3" ]]; then
1616
echo "Error! Requiring 3 parameters! Received $# ($*)."
1717
usagehelp # The function to print help
1818
fi

scripts_data/interactive5.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ while getopts "hvi:o:a:" INITARGS; do
1313
exit # Terminate after providing help
1414
;; # End of this option
1515
i) # Parameter "-i" accepts some value (e.g. "-i inputfile.txt")
16-
if [ -r "${OPTARG}" ]; then # Check if the input file exists and is readable
16+
if [[ -r "${OPTARG}" ]]; then # Check if the input file exists and is readable
1717
echo "OK, File \"${OPTARG}\" exists and is readable. Proceeding..."
1818
INPUTFILE="${OPTARG}" # $OPTARG always contains value of parameter
1919
else
@@ -23,7 +23,7 @@ while getopts "hvi:o:a:" INITARGS; do
2323
fi
2424
;; # End of this option
2525
o) # Parameter "-o" accepts some value (e.g. "-o outputfile.txt")
26-
if [ -n "${OPTARG}" ]; then # Check if there is some name for output variable
26+
if [[ -n "${OPTARG}" ]]; then # Check if there is some name for output variable
2727
echo "OK, Name for output file was provided: \"${OPTARG}\". Proceeding..."
2828
OUTPUTFILE="${OPTARG}" # $OPTARG always contains value of parameter
2929
else
@@ -34,7 +34,7 @@ while getopts "hvi:o:a:" INITARGS; do
3434
;; # End of this option
3535
a) # Parameter "-a" accepts some value (e.g. "-a X" for number)
3636
# Check if provided value makes sense (integer between 10 and 300)
37-
if [[ "${OPTARG}" =~ ^[0-9]+$ ]] && [ "${OPTARG}" -ge 10 ] && [ "${OPTARG}" -le 300 ]; then # The condition is long...
37+
if [[ "${OPTARG}" =~ ^[0-9]+$ ]] && [[ "${OPTARG}" -ge 10 ]] && [[ "${OPTARG}" -le 300 ]]; then # The condition is long...
3838
VALUE=${OPTARG} # $OPTARG always contains value of parameter
3939
echo "Value is OK: ${VALUE}"
4040
else
@@ -52,14 +52,14 @@ done
5252

5353
# Check if all required values are provided
5454

55-
if [ -z "${INPUTFILE}" ] || [ -z "${OUTPUTFILE}" ]; then
55+
if [[ -z "${INPUTFILE}" ]] || [[ -z "${OUTPUTFILE}" ]]; then
5656
echo "Error! Name of input and/or output file was not provided!"
5757
echo "See \"$0 -h\" for help usage..."
5858
echo
5959
exit 1
6060
fi
6161

62-
if [ -z "${VALUE}" ]; then
62+
if [[ -z "${VALUE}" ]]; then
6363
echo "Warning! Value for \"-a\" was not provided! Using default value of 10."
6464
VALUE=10
6565
fi

scripts_data/interactive6.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

33
# We expect exactly one parameter
4-
if [ "$#" -ne "1" ]; then
4+
if [[ "$#" -ne "1" ]]; then
55
echo "Error! Exactly one parameter is required!"
66
exit 1
77
fi
88

99
# Verify that file exists and is readable
10-
if [ ! -r "$1" ]; then
10+
if [[ ! -r "$1" ]]; then
1111
echo "Error! The file provided does not exist or is not readable!"
1212
exit 1
1313
fi

scripts_data/metacentrum_oxalis.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trap 'cp -a "${SCRATCHDIR}" "${DATADIR}"/ && clean_scratch' TERM
1616

1717
# Required modules
1818
echo "Loading module(s)"
19-
module add iqtree-1.6.12 || exit 1 # iqtree
19+
module add iqtree-1.6.12 || exit 1
2020
echo
2121

2222
# Change working directory
@@ -31,7 +31,7 @@ cp -a "${DATADIR}"/"${DATAFSA}" "${SCRATCHDIR}"/ || exit 1
3131
echo
3232

3333
echo "Computing gene tree from ${DATAFSA}..."
34-
iqtree -s "${DATAFSA}" -st DNA -nt 1 -m MFP+I+R+P -lmap ALL -cmax 1000 -nstop 1000 -alrt 10000 -bb 10000 -bnni || exit 1
34+
iqtree -s "${DATAFSA}" -st DNA -nt 1 -m MFP+I+R+P -lmap ALL -cmax 1000 -nstop 1000 -alrt 10000 -bb 10000 -bnni || { export CLEAN_SCRATCH='false'; exit 1; }
3535
echo
3636

3737
# Copy results back to home directory

0 commit comments

Comments
 (0)