diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index 95015f7..1644675 100644 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -258,7 +258,9 @@ subcommand_generic0() { print_help "${subcommand}" ;; -- ) - : + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -284,7 +286,9 @@ subcommand_generic1() { print_help "${subcommand}" ;; -- ) - : + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -314,7 +318,9 @@ subcommand_generic1plus() { print_help "${subcommand}" ;; -- ) - : + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -477,6 +483,9 @@ subcommand_load() { verbosity_lvl='warn' ;; -- ) + shift 1 + args+=( "$@" ) + break ;; * ) args+=( $1 ) @@ -678,6 +687,9 @@ subcommand_unload() { print_help "${subcommand}" ;; -- ) + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -744,6 +756,9 @@ subcommand_swap() { print_help "${subcommand}" ;; -- ) + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -798,6 +813,9 @@ subcommand_show() { print_help "${subcommand}" ;; -- ) + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -972,6 +990,8 @@ subcommand_avail() { (( n > max_length )) && (( max_length=n )) available_modules+=("${mod}") done + IFS=$'\n' available_modules=($(sort --version-sort <<<"${available_modules[*]}")) + unset IFS local -i span=$(( max_length / 16 + 1 )) # compute column size local -i colsize=$(( span * 16 )) # as multiple of 16 local -i column=$cols # force a line-break @@ -1025,7 +1045,12 @@ subcommand_avail() { fi opt_groups[${val}]=1 ;; - -- | '' ) + '' ) + ;; + -- ) + shift 1 + pattern+=( "$@" ) + break ;; * ) pattern+=( "$1" ) @@ -1042,8 +1067,12 @@ subcommand_avail() { local string for string in "${pattern[@]}"; do for dir in "${modulepath[@]}"; do - local group="${dir/${PMODULES_ROOT}\/}" - group="${group%%/*}" + if [[ ${dir} =~ ${PMODULES_ROOT} ]]; then + local group="${dir/${PMODULES_ROOT}\/}" + group="${group%%/*}" + else + local group="${dir}" + fi if (( ${#opt_groups[@]} > 0 )) && [[ ! -v opt_groups[${group}] ]]; then continue fi @@ -1213,6 +1242,9 @@ subcommand_use() { add2path_func='std::prepend_path' ;; -- ) + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -1318,6 +1350,9 @@ subcommand_unuse() { print_help "${subcommand}" ;; -- ) + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -1476,6 +1511,9 @@ subcommand_purge() { print_help "${subcommand}" ;; -- ) + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -1571,6 +1609,9 @@ subcommand_list() { opts+=( '-t' ) ;; -- ) + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -1609,7 +1650,9 @@ subcommand_clear() { print_help "${subcommand}" ;; -- ) - : + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -1967,6 +2010,9 @@ subcommand_search() { opt_wrap='yes' ;; -- ) + shift 1 + modules+=( "$@" ) + break ;; * ) modules+=( "$1" ) @@ -2048,7 +2094,9 @@ subcommand_help() { print_help 'version' ;; -- ) - : + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -2203,7 +2251,9 @@ subcommand_initswitch() { print_help "${subcommand}" ;; -- ) - : + shift 1 + args+=( "$@" ) + break ;; * ) args+=( "$1" ) @@ -2282,7 +2332,7 @@ while (( $# > 0 )); do --debug ) set -x ;; - '' | -- ) + '' ) ;; -* ) opts+=( "$1" ) @@ -2373,7 +2423,7 @@ case ${subcommand} in esac declare options -options=$( "${getopt}" ${Options[${subcommand}]} -- -- "${opts[@]}" "$@" ) \ +options=$( "${getopt}" ${Options[${subcommand}]} -- "${opts[@]}" "$@" ) \ || print_help "${subcommand}" eval set -- ${options} subcommand_${Subcommands[$subcommand]} "$@"