#4 module(1) should return status

None
open
R.K. Owen
None
5
2014-12-10
2008-07-18
Anonymous
No

Hello,

The module(1) command really should have a significant return value, so it can be used in scripts. For instance
when trying to load a non-existant module the command
prints:
ModuleCmd_Load.c(200):ERROR:105: Unable to locate a modulefile for 'doesnotexist'
but still returns 0.
How to solve it:
If modulecmd detects an error, it should print
"false" as the last statement to stdout, and since the
output is evaluated by the shell, the return
value will be non-zero.

Thanks,

Peter

Related

Feature Requests: #4

Discussion

  • R.K. Owen
    R.K. Owen
    2012-11-12

    • assigned_to: R.K. Owen
    • milestone: -->
     
  • R.K. Owen
    R.K. Owen
    2012-11-12

    Instead of "false" I would use "test 0 = 1" to return a non-zero exit status.
    I'll look at this and evaluate what errors to flag.

     
  • R.K. Owen
    R.K. Owen
    2013-06-19

    Should be an option added to enable this, because some people may be relying on the traditional behavior.

     
  • Carl Ponder
    Carl Ponder
    2014-08-02

    I use the module command from inside scrpts that begin with

    #!/bin/bash -ex

    My intent is that the script automatically aborts when a command fails. This has not been the case with the "module load" commands, I can see a load fail but the script continues along using the wrong environment. It would be much easier to diagnose/fix if the script had aborted as designed.

     
    Last edit: Carl Ponder 2014-08-02
  • Carl Ponder
    Carl Ponder
    2014-10-26

    I'd suggest that when the "module" command fails and gives a nonzero exit value, it could print a message apologizing for the new behavior and refer the user to the (new) version of the man-page for explanation. This would be easier than adding the guts to process a new command-line flag.

    This ought to just be a 2-line change. The request went in six years ago. could you please make the fix and release it?

     
    • Eric Deveaud
      Eric Deveaud
      2014-11-09

      can you please check the current git master branch.

      module load XYZ (with non existing XYZ modulefile) will exit with
      1) test 0 = 1 evaled
      2) modulecmd itself will also exit with non zero return val (used for other interpreters callers to module eg perl, python, etc...)

       
  • Carl Ponder
    Carl Ponder
    2014-12-10

    I did the

    git clone git://git.code.sf.net/p/modules/git modules-git

    but don't have any modules-git/configure script. Can you point me to the build instructions? If I read right, the modules-git/INSTALL indicates it should be there.

     
    • Eric Deveaud
      Eric Deveaud
      2014-12-10

      Carl Ponder carlponder@users.sf.net écrit :

      I did the

      git clone git://git.code.sf.net/p/modules/git modules-git

      but don't have any modules-git/configure script. Can you point me to the
      build instructions? If I read right, the modules-git/INSTALL indicates it
      should be there.

      in order to generate the configure script, you shoul issue the folloewing command:

      autoreconf -f -i

      this will produce the configure script to use.

      regards
      
      Eric
      
       
  • Carl Ponder
    Carl Ponder
    2014-12-10

    Also, would you consider bundling my "fix" for the xtrace'ing

    https://sourceforge.net/p/modules/feature-requests/15/

    and spinning a 3.2.11 release?

     
    • Eric Deveaud
      Eric Deveaud
      2014-12-10

      Carl Ponder carlponder@users.sf.net écrit :

      Also, would you consider bundling my "fix" for the xtrace'ing

      https://sourceforge.net/p/modules/feature-requests/15/

      and spinning a 3.2.11 release?

      I would rather suggest that you do the modification at your site level or script level

      the"garbage" you see displayed is the normal behaviour of the avaluation of modulecmd setting the environmeent
      the [[ braceexpand:hashall:histexpand:history: is spitted by the shell you use.

      module is NOT a command is a shell specific function that set your environment based on the output or modulecmd (which is the command)

      all you see on the xtrace output is the shell behaviour.

      in a naive way I would do something like that:

      cixi:~ > cat foo.sh

      !#/bin/bash

      set -x

      silentmodule()
      {
      set +x
      module ${1+"$@"}
      set -x
      }

      echo "silencing module call"
      silentmodule load whatever

      best regards
      
      Eric
      

      [feature-requests:#4] module(1) should return status

      Status: open
      Group:
      Created: Fri Jul 18, 2008 07:22 AM UTC by Anonymous
      Last Updated: Wed Dec 10, 2014 09:15 AM UTC
      Owner: R.K. Owen

      Hello,

      The module(1) command really should have a significant return value, so it can be used in scripts. For instance
      when trying to load a non-existant module the command
      prints:
      ModuleCmd_Load.c(200):ERROR:105: Unable to locate a modulefile for 'doesnotexist'
      but still returns 0.
      How to solve it:
      If modulecmd detects an error, it should print
      "false" as the last statement to stdout, and since the
      output is evaluated by the shell, the return
      value will be non-zero.

      Thanks,

      Peter
      

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/modules/feature-requests/4/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Feature Requests: #4