From 2739df53ecba42706cf44c3727d31f63f06866be Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 20 Apr 2017 11:28:33 +0200 Subject: [PATCH] Pmodules/modulecmd.bash.in - accept shebangs like '#%Module17.3' for traditional modulefile - accept shebang '#%Pmodule' for modulefiles using Pmodules extensions (fixing #18) - stub added for printing CSV output in search command (see issue #19) --- Pmodules/modulecmd.bash.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 3ccd025..80b97af 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -510,7 +510,7 @@ is_modulefile() { local shebang [[ -r ${fname} ]] || return 1 read -n 11 shebang < "${fname}" - [[ "${shebang}" == "#%Module1.0" ]] + [[ "${shebang:0:8}" == "#%Module" ]] || [[ "${shebang:0:9}" == "#%Pmodule" ]] || } subcommand_generic0() { @@ -1519,6 +1519,7 @@ subcommand_search() { local opt_print_header='yes' local opt_print_modulefiles='no' local opt_print_variants='no' + local opt_print_csv='no' local opt_use_releases=':' local -r fmt="%-20s %-10s %-12s %-s\n" @@ -1599,6 +1600,10 @@ subcommand_search() { done printf "%-20s %-10s %-s\n" "${toks[0]}" "${toks[1]}" "${dependecies}" 1>&2 done < <("${sort}" -k 1,1 -k 4,4 -k 5,5 "${tmpfile}" | awk "${with_modules}") + elif [[ "${opt_print_csv}" == "yes" ]]; then + while read -a toks; do + : + done < <("${sort}" -k 1,1 -k 4,4 -k 5,5 "${tmpfile}" | awk "${with_modules}") else "${sort}" -k 1,1 -k 4,4 -k 5,5 "${tmpfile}" | awk "${with_modules}" 1>&2 fi @@ -1642,6 +1647,7 @@ subcommand_search() { # get and print all available modules in $mpath # with respect to the requested releases + # tmpfile: module/version release group group-dependencies... local mods=( $( get_available_modules \ "${mpath}" \ "${module}" \ @@ -1666,6 +1672,7 @@ subcommand_search() { -l all-releases \ -l src: \ -l print-variants \ + -l print-csv \ -- "$@") || subcommand_help_${subcommand} eval set -- "${opts}" @@ -1678,6 +1685,10 @@ subcommand_search() { opt_print_modulefiles='yes' opt_print_header='no' ;; + --print-csv ) + opt_print_csv='yes' + opt_print_header='no' + ;; --release ) is_release "$2" || \ std::die 1 "${CMD} search: illegal release name -- $2"