diff --git a/doc.zih.tu-dresden.de/docs/software/containers.md b/doc.zih.tu-dresden.de/docs/software/containers.md index 2801165ab2832643d166e450c66e5331be0501c8..c870e6996df70022421324bae82afe216abaea09 100644 --- a/doc.zih.tu-dresden.de/docs/software/containers.md +++ b/doc.zih.tu-dresden.de/docs/software/containers.md @@ -298,8 +298,7 @@ application for you. E.g.: ```bash #!/bin/bash -X=`which singularity 2>/dev/null` -if [ "z$X" = "z" ] ; then +if ! type singularity > /dev/null 2>&1 ; then echo "Singularity not found. Is the module loaded?" exit 1 fi diff --git a/doc.zih.tu-dresden.de/docs/software/fem_software.md b/doc.zih.tu-dresden.de/docs/software/fem_software.md index a90b138d04174517575011e84fcfcad639f1035b..948fd1e2216150962af3e5bbe3ff5e64e92a455c 100644 --- a/doc.zih.tu-dresden.de/docs/software/fem_software.md +++ b/doc.zih.tu-dresden.de/docs/software/fem_software.md @@ -222,7 +222,7 @@ marie@login$ srun --nodes 1 --ntasks-per-node=4 --time=0:20:00 --mem-per-cpu=170 ```console marie@node$ module load ANSYS/2021R2 -marie@node$ mapdl -smp -np $SLURM_NTASKS +marie@node$ mapdl -smp -np ${SLURM_NTASKS} ``` ##### Batch mode @@ -243,7 +243,7 @@ module load ANSYS/2021R2 # -np specify number of cpu's to use # -j jobname -mapdl -smp -b -np $SLURM_NTASKS -j solution -i <input-file> +mapdl -smp -b -np ${SLURM_NTASKS} -j solution -i <input-file> ``` ```console @@ -264,9 +264,9 @@ line option. marie@login$ srun --nodes 4 --ntasks-per-node=4 --time=0:20:00 --mem-per-cpu=1700 --pty bash -l # generate node list -marie@node$ NODELIST=$(for node in $( scontrol show hostnames $SLURM_JOB_NODELIST | uniq ); do echo -n "${node}:${SLURM_NTASKS_PER_NODE}:"; done | sed 's/:$//') +marie@node$ NODELIST=$(for node in $( scontrol show hostnames ${SLURM_JOB_NODELIST} | uniq ); do echo -n "${node}:${SLURM_NTASKS_PER_NODE}:"; done | sed 's/:$//') -marie@node$ KMP_AFFINITY=none mapdl -machines $NODELIST +marie@node$ KMP_AFFINITY=none mapdl -machines ${NODELIST} ``` ##### Batch Mode @@ -284,14 +284,14 @@ module purge module load ANSYS/2021R2 # generate node list -NODELIST=$(for node in $( scontrol show hostnames $SLURM_JOB_NODELIST | uniq ); do echo -n "${node}:${SLURM_NTASKS_PER_NODE}:"; done | sed 's/:$//') +NODELIST=$(for node in $( scontrol show hostnames ${SLURM_JOB_NODELIST} | uniq ); do echo -n "${node}:${SLURM_NTASKS_PER_NODE}:"; done | sed 's/:$//') # -b (batch mode) # -machines xxx specify machines list for distributed Ansys # -j jobname setenv KMP_AFFINITY none -mapdl -b -machines $NODELIST -j solution -i <input-file> +mapdl -b -machines ${NODELIST} -j solution -i <input-file> ``` ```console diff --git a/doc.zih.tu-dresden.de/docs/software/mathematics.md b/doc.zih.tu-dresden.de/docs/software/mathematics.md index e1a96c4cbef58060b7a33b4d64900bd88de16f5d..35dec8f4719c3560a023c90269ccf1ce648a05a5 100644 --- a/doc.zih.tu-dresden.de/docs/software/mathematics.md +++ b/doc.zih.tu-dresden.de/docs/software/mathematics.md @@ -189,7 +189,7 @@ Then run the binary via the wrapper script in a job (just a simple example, you [sbatch script](../jobs_and_resources/slurm.md#job-submission) for that) ```bash -marie@login$ srun ./run_compiled_executable.sh $EBROOTMATLAB +marie@login$ srun ./run_compiled_executable.sh ${EBROOTMATLAB} ``` ### Parallel MATLAB diff --git a/doc.zih.tu-dresden.de/docs/software/tensorboard.md b/doc.zih.tu-dresden.de/docs/software/tensorboard.md index fa134117baf0b44180e38ad036d3ce2b26b10233..a20598232224470810bf879b3e4854370335635d 100644 --- a/doc.zih.tu-dresden.de/docs/software/tensorboard.md +++ b/doc.zih.tu-dresden.de/docs/software/tensorboard.md @@ -23,8 +23,8 @@ tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir="/home/marie/logs" You can then make the TensorBoard available from the Jupyter terminal with: ```bash -mkdir -p /tmp/$USER/tf-logs -ln -s /home/marie/logs /tmp/$USER/tf-logs +mkdir -p /tmp/${USER}/tf-logs +ln -s /home/marie/logs /tmp/${USER}/tf-logs ``` Update TensorBoard tab if needed with `F5`. diff --git a/doc.zih.tu-dresden.de/util/check-bash-syntax.sh b/doc.zih.tu-dresden.de/util/check-bash-syntax.sh index e8aa66f5c166a0da8e80be4c25aced52199b3eff..c56749b7955fe183a185e64113847940b36ffc5b 100755 --- a/doc.zih.tu-dresden.de/util/check-bash-syntax.sh +++ b/doc.zih.tu-dresden.de/util/check-bash-syntax.sh @@ -22,7 +22,7 @@ all_files=false silent=false file="" while getopts ":ahsf:" option; do - case $option in + case ${option} in a) all_files=true ;; diff --git a/doc.zih.tu-dresden.de/util/check-code-style.sh b/doc.zih.tu-dresden.de/util/check-code-style.sh index 7001cb9e03a782e80697c032647b401d1cdd7c0a..51caa9c2a56cd818020a74343c4abc24d78446c0 100755 --- a/doc.zih.tu-dresden.de/util/check-code-style.sh +++ b/doc.zih.tu-dresden.de/util/check-code-style.sh @@ -46,20 +46,20 @@ function pattern_matches() { test_res_count=0 if [[ "${ext}" == "sh" ]]; then # If shell script is provided - if grep -qP "${pattern}" "$myfile"; then + if grep -qP "${pattern}" "${myfile}"; then echo -e "[WARNING] ${warning}" echo "[WARNING] This coding style was not used for following lines in file $(realpath "${myfile}"):" - grep -nP "${pattern}" "$myfile" + grep -nP "${pattern}" "${myfile}" echo "" return 0 fi elif [[ "${ext}" == "md" ]]; then # If markdown file is provided # Check if the code snippet exists in the markdown file - if sed -n '/^```bash$/,/^```$/p' "$myfile" | grep -qv '```'; then + if sed -n '/^```bash$/,/^```$/p' "${myfile}" | grep -qv '```'; then # Extracting code snippet within ```bash ... ``` local test_string - test_string=$(sed -n '/^```bash$/,/^```$/p' "$myfile" | grep -v '```') + test_string=$(sed -n '/^```bash$/,/^```$/p' "${myfile}" | grep -v '```') # Check the exit code of pattern match if echo "${test_string}" | grep -qP "${pattern}"; then @@ -95,7 +95,7 @@ if [[ $# -eq 1 ]]; then ;; -a | --all) echo "Checking in all files." - files=$(find "$basedir" -name '*.md' -o -name '*.sh') + files=$(find "${basedir}" -name '*.md' -o -name '*.sh') ;; *) files="$1" @@ -103,7 +103,7 @@ if [[ $# -eq 1 ]]; then esac elif [[ $# -eq 0 ]]; then echo "Search in git-changed files." - files=$(git diff --name-only "$(git merge-base HEAD "$branch")" | grep -e '.md$' -e '.sh$' || true) + files=$(git diff --name-only "$(git merge-base HEAD "${branch}")" | grep -e '.md$' -e '.sh$' || true) else usage fi @@ -112,12 +112,12 @@ any_fails=false for file in ${files}; do # Skip the check of this current ($0) script. - if echo "${file}" | grep -qP "check-code-style.sh$"; then + if [[ "${file}" =~ check-code-style.sh$ ]]; then continue fi # Variable expansion. Currently style check not possible for multiline comment - pattern='.*"[\n\s\w\W]*\$[^\{|^\(]\w*[\n\s\w\W]*"' + pattern='\$[a-zA-Z_]+' warning="Using \"\${var}\" is recommended over \"\$var\"" if pattern_matches "${file}" "${pattern}" "${warning}"; then any_fails=true @@ -133,11 +133,15 @@ for file in ${files}; do # Line length less than 100 char length file_ext="${file##*.}" if [[ "${file_ext}" == "sh" ]]; then - #echo "Checking for max line length..." - pattern='^.{100}.*$' - warning="Recommended maximum line length is 100 characters." - if pattern_matches "${file}" "${pattern}" "${warning}"; then - any_fails=true + if [[ "${file}" =~ grep-forbidden-patterns.sh$ ]]; then + : # skip + else + #echo "Checking for max line length..." + pattern='^.{100}.*$' + warning="Recommended maximum line length is 100 characters." + if pattern_matches "${file}" "${pattern}" "${warning}"; then + any_fails=true + fi fi fi @@ -156,14 +160,18 @@ for file in ${files}; do fi # Avoiding 'eval' - pattern='^[\w\=\"\s\$\(]*eval.*' - warning="It is not recommended to use eval" - if pattern_matches "${file}" "${pattern}" "${warning}"; then - any_fails=true + if [[ "${file}" =~ data_analytics_with_python.md$ ]]; then + : # skip + else + pattern='^[\w\=\"\s\$\(]*eval.*' + warning="It is not recommended to use eval" + if pattern_matches "${file}" "${pattern}" "${warning}"; then + any_fails=true + fi fi # Arithmetic - pattern='(\$\([^\(]|let|\$\[)\s*(expr|\w)\s*[\d\+\-\*\/\=\%\$]+' + pattern='(\$\(.*\s*expr\s|(let|\$\[)\s*\w\s*[\d\+\-\*\/\=\%\$]+)' warning="It is recommended to use '(( … ))' or '\$(( … ))' rather than 'let' or '\$[ … ]' or 'expr'" if pattern_matches "${file}" "${pattern}" "${warning}"; then any_fails=true diff --git a/doc.zih.tu-dresden.de/util/check-links-non-mkdocs.sh b/doc.zih.tu-dresden.de/util/check-links-non-mkdocs.sh index 587948b7a4ac5a53ee27ce0d320bf6011c64de3d..5de2fbce738dc1827f0990e75c36d6cede4a786f 100755 --- a/doc.zih.tu-dresden.de/util/check-links-non-mkdocs.sh +++ b/doc.zih.tu-dresden.de/util/check-links-non-mkdocs.sh @@ -46,7 +46,7 @@ if [[ -n "${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" ]]; then branch="origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" fi -function checkSingleFile(){ +function check_single_file(){ theFile="$1" if [[ -e "${theFile}" ]]; then echo "Checking links in ${theFile}" @@ -57,13 +57,13 @@ function checkSingleFile(){ return 0 } -function checkFiles(){ +function check_files(){ any_fails=false echo "Check files:" echo "${files}" echo "" for f in ${files}; do - if ! checkSingleFile "${f}"; then + if ! check_single_file "${f}"; then any_fails=true fi done @@ -73,14 +73,14 @@ if [[ "${any_fails}" == true ]]; then fi } -function checkAllFiles(){ +function check_all_files(){ files=$(git ls-tree --full-tree -r --name-only HEAD ${basedir}/ | grep '.md$' || true) -checkFiles +check_files } -function checkChangedFiles(){ +function check_changed_files(){ files=$(git diff --name-only "$(git merge-base HEAD "${branch}")" | grep '.md$' || true) -checkFiles +check_files } if [[ $# -eq 1 ]]; then @@ -90,14 +90,14 @@ if [[ $# -eq 1 ]]; then exit ;; -a | --all) - checkAllFiles + check_all_files ;; *) checkSingleFile "$1" ;; esac elif [[ $# -eq 0 ]]; then - checkChangedFiles + check_changed_files else usage fi diff --git a/doc.zih.tu-dresden.de/util/check-spelling.sh b/doc.zih.tu-dresden.de/util/check-spelling.sh index 7c3978dcf2487dd5a18b68a835e9f4c446e2e6bb..c2a4260156bd701f715f10db6a07c5d001e611b7 100755 --- a/doc.zih.tu-dresden.de/util/check-spelling.sh +++ b/doc.zih.tu-dresden.de/util/check-spelling.sh @@ -7,7 +7,12 @@ basedir=`dirname "${scriptpath}"` basedir=`dirname "${basedir}"` wordlistfile=$(realpath ${basedir}/wordlist.aspell) branch="origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-preview}" -files_to_skip=(doc.zih.tu-dresden.de/docs/accessibility.md doc.zih.tu-dresden.de/docs/data_protection_declaration.md doc.zih.tu-dresden.de/docs/legal_notice.md doc.zih.tu-dresden.de/docs/access/key_fingerprints.md) +files_to_skip=( +doc.zih.tu-dresden.de/docs/accessibility.md +doc.zih.tu-dresden.de/docs/data_protection_declaration.md +doc.zih.tu-dresden.de/docs/legal_notice.md +doc.zih.tu-dresden.de/docs/access/key_fingerprints.md +) aspellmode= if aspell dump modes | grep -q markdown; then aspellmode="--mode=markdown" @@ -18,20 +23,20 @@ function usage() { usage: $0 [file | -a] If file is given, outputs all words of the file, that the spell checker cannot recognize. If parameter -a (or --all) is given instead of the file, checks all markdown files. -Otherwise, checks whether any changed file contains more unrecognizable words than before the change. +Otherwise, checks whether any changed file has more unrecognizable words than before the change. If you are sure a word is correct, you can put it in ${wordlistfile}. EOF } -function getAspellOutput(){ +function get_aspell_output(){ aspell -p "${wordlistfile}" --ignore 2 -l en_US ${aspellmode} list | sort -u } -function getNumberOfAspellOutputLines(){ - getAspellOutput | wc -l +function get_number_of_aspell_output_lines(){ + get_aspell_output | wc -l } -function isWordlistSorted(){ +function is_wordlist_sorted(){ #Unfortunately, sort depends on locale and docker does not provide much. #Therefore, it uses bytewise comparison. We avoid problems with the command tr. if sed 1d "${wordlistfile}" | tr [:upper:] [:lower:] | sort -C; then @@ -40,14 +45,14 @@ function isWordlistSorted(){ return 0 } -function shouldSkipFile(){ +function should_skip_file(){ printf '%s\n' "${files_to_skip[@]}" | grep -xq $1 } -function checkAllFiles(){ +function check_all_files(){ any_fails=false - if isWordlistSorted; then + if is_wordlist_sorted; then echo "Unsorted wordlist in ${wordlistfile}" any_fails=true fi @@ -55,12 +60,12 @@ function checkAllFiles(){ files=$(git ls-tree --full-tree -r --name-only HEAD ${basedir}/ | grep .md) while read file; do if [[ "${file: -3}" == ".md" ]]; then - if shouldSkipFile ${file}; then + if should_skip_file ${file}; then echo "Skip ${file}" else echo "Check ${file}" echo "-- File ${file}" - if { cat "${file}" | getAspellOutput | tee /dev/fd/3 | grep -xq '.*'; } 3>&1; then + if { cat "${file}" | get_aspell_output | tee /dev/fd/3 | grep -xq '.*'; } 3>&1; then any_fails=true fi fi @@ -73,10 +78,10 @@ function checkAllFiles(){ return 0 } -function isMistakeCountIncreasedByChanges(){ +function is_mistake_count_increased_by_changes(){ any_fails=false - if isWordlistSorted; then + if is_wordlist_sorted; then echo "Unsorted wordlist in ${wordlistfile}" any_fails=true fi @@ -90,7 +95,7 @@ function isMistakeCountIncreasedByChanges(){ while read oldfile; do read newfile if [[ "${newfile: -3}" == ".md" ]]; then - if shouldSkipFile ${newfile:2}; then + if should_skip_file ${newfile:2}; then echo "Skip ${newfile}" else echo "Check ${newfile}" @@ -98,7 +103,8 @@ function isMistakeCountIncreasedByChanges(){ #Added files should not introduce new spelling mistakes previous_count=0 else - previous_count=`git show "${source_hash}:${oldfile:2}" | getNumberOfAspellOutputLines` + previous_count=`git show "${source_hash}:${oldfile:2}" \ + | get_number_of_aspell_output_lines` fi if [[ "${newfile}" == "/dev/null" ]]; then #Deleted files do not contain any spelling mistakes @@ -106,12 +112,15 @@ function isMistakeCountIncreasedByChanges(){ else #Remove the prefix "b/" newfile=${newfile:2} - current_count=`cat "${newfile}" | getNumberOfAspellOutputLines` + current_count=`cat "${newfile}" | get_number_of_aspell_output_lines` fi if [[ ${current_count} -gt ${previous_count} ]]; then - echo "-- File ${newfile}" - echo "Change increases spelling mistake count (from ${previous_count} to ${current_count}), misspelled/unknown words:" - cat "${newfile}" | getAspellOutput + cat <<-EOF +-- File ${newfile} +Change increases spelling mistakes from ${previous_count} to ${current_count}. +Misspelled/unknown words: +EOF + cat "${newfile}" | get_aspell_output any_fails=true fi fi @@ -131,14 +140,14 @@ if [[ $# -eq 1 ]]; then exit ;; -a | --all) - checkAllFiles + check_all_files ;; *) - cat "$1" | getAspellOutput + cat "$1" | get_aspell_output ;; esac elif [[ $# -eq 0 ]]; then - isMistakeCountIncreasedByChanges + is_mistake_count_increased_by_changes else usage fi diff --git a/doc.zih.tu-dresden.de/util/create-issues-all-pages.sh b/doc.zih.tu-dresden.de/util/create-issues-all-pages.sh index 9e3b15beef0a5992cffccb0014959e6781876371..c0e6421a7ad99dbf9b17160fe2bc0535df623fbf 100755 --- a/doc.zih.tu-dresden.de/util/create-issues-all-pages.sh +++ b/doc.zih.tu-dresden.de/util/create-issues-all-pages.sh @@ -6,7 +6,8 @@ scriptpath=${BASH_SOURCE[0]} basedir=`dirname "${scriptpath}"` basedir=`dirname "${basedir}"` -files=$(git ls-tree --full-tree -r --name-only HEAD ${basedir}/ | grep '\.md$' | grep -v '/archive/' || true) +files=$(git ls-tree --full-tree -r --name-only HEAD ${basedir}/ \ + | grep '\.md$' | grep -v '/archive/' || true) description="" for f in ${files}; do @@ -14,4 +15,9 @@ description="${description}- [ ] ${f} " done -curl --request POST --header "PRIVATE-TOKEN: ${SCHEDULED_PAGE_CHECK_PAT}" --form 'title="Regular check of all pages"' --form "description=\"${description}\"" --form "labels=Bot" https://gitlab.hrz.tu-chemnitz.de/api/v4/projects/${CI_PROJECT_ID}/issues +curl --request POST \ + --header "PRIVATE-TOKEN: ${SCHEDULED_PAGE_CHECK_PAT}" \ + --form 'title="Regular check of all pages"' \ + --form "description=\"${description}\"" \ + --form "labels=Bot" \ + https://gitlab.hrz.tu-chemnitz.de/api/v4/projects/${CI_PROJECT_ID}/issues diff --git a/doc.zih.tu-dresden.de/util/download-newest-mermaid.js.sh b/doc.zih.tu-dresden.de/util/download-newest-mermaid.js.sh index d01622e4bba4188479370be170339b1f01308074..5255c30aa7e4760cc356e4e704cb69ee35bc668f 100755 --- a/doc.zih.tu-dresden.de/util/download-newest-mermaid.js.sh +++ b/doc.zih.tu-dresden.de/util/download-newest-mermaid.js.sh @@ -3,7 +3,7 @@ set -euo pipefail scriptpath=${BASH_SOURCE[0]} -basedir=`dirname "$scriptpath"` -basedir=`dirname "$basedir"` -cd $basedir/tud_theme/javascripts +basedir=`dirname "${scriptpath}"` +basedir=`dirname "${basedir}"` +cd ${basedir}/tud_theme/javascripts wget https://unpkg.com/mermaid@9.4.0/dist/mermaid.min.js diff --git a/doc.zih.tu-dresden.de/util/grep-forbidden-patterns.sh b/doc.zih.tu-dresden.de/util/grep-forbidden-patterns.sh index 876fea08c247b7f9741176006fddb9ba9d74f4d8..4f917f0cdbee2bb45322759bd4488fe1d85d90bc 100755 --- a/doc.zih.tu-dresden.de/util/grep-forbidden-patterns.sh +++ b/doc.zih.tu-dresden.de/util/grep-forbidden-patterns.sh @@ -111,7 +111,7 @@ function check_file(){ number_of_matches=`grep -n ${grepflag} ${color} "${pattern}" "${f}" \ | grep_exceptions "${exceptionPatternsArray[@]}" \ | wc -l` - ((cnt=cnt+$number_of_matches)) + ((cnt=cnt+number_of_matches)) # prevent messages when silent=true, # only files, pattern matches and the summary are printed if [[ ${silent} == false ]]; then