[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [UDD] Help needed for exit code of udd.py



* Andreas Tille <andreas@an3as.eu>, 2012-02-19, 12:41:
--- udd.py      (Revision 2154)
+++ udd.py      (Arbeitskopie)
@@ -62,6 +62,7 @@
        if "update-command" in src_config:
          result = system(src_config['update-command'])
          if result != 0:
+            print "False =", result
            sys.exit(result)
        end_time = get_timestamp()
      else:


and tried:

$ udd.py config-org.yaml update bibref && echo test
False = 2048
test


Could anybody explain why if the python script exits a non-zero value the second part of the statement (&& echo test) is executed?

This is not explicitly documented in Python documentation, but the sys.exit() function behaves like the C exit() function with respect to exit codes:

“The exit() function causes normal process termination and the value of status & 0377 is returned to the parent […].”

2048 & 0377 == 0

You probably want to replace "sys.exit(result)" with "sys.exit(1)".

--
Jakub Wilk


Reply to: