nobs loses exit code when piping errors to PAGER

Issue #35 resolved
Dan Bonachea created an issue

Nobs is exiting with the a zero exit code on Linux (pcp-d) after generating an error that consumes more lines that fit on the terminal.

Example of correct behavior, for a synthetic error:

$ . sourceme
$ rm -Rf .nobs/ ; env PAGER=cat CXX=noexists nobs exe test/future.cpp ; echo $?                                              
noexists -std=c++11 -D_GNU_SOURCE=1 -I/home/pcp1/bonachea/UPC/upcxx/.nobs/art/9567f52ffd5df5bcd59711dba1d52b9d76423aa5 -MM -MT x /home/pcp1/bonachea/UPC/upcxx/test/future.cpp

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Uncaught exception

Traceback (most recent call last):
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/tool_main.py", line 87, in main
    printed.wait()
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/async.py", line 447, in wait
    return me.wait_futurized().value()
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/async.py", line 751, in fire
    arg = gen_throw(arg.exception, None, arg.traceback)
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/memodb.py", line 438, in memo_execute
    yield result
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/async.py", line 751, in fire
    arg = gen_throw(arg.exception, None, arg.traceback)
  File "/home/pcp1/bonachea/UPC/upcxx/nobsrule.py", line 536, in execute
    objs, libset = yield me.crawl()
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/async.py", line 751, in fire
    arg = gen_throw(arg.exception, None, arg.traceback)
  File "/home/pcp1/bonachea/UPC/upcxx/nobsrule.py", line 508, in crawl
    yield fresh_src(main_src)
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/async.py", line 601, in fire1
    proxied = lam(arg_result)
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/memodb.py", line 520, in result
    return resultoid()
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/async.py", line 751, in fire
    arg = gen_throw(arg.exception, None, arg.traceback)
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/memodb.py", line 438, in memo_execute
    yield result
  File "/home/pcp1/bonachea/UPC/upcxx/nobs/nobs/async.py", line 749, in fire
    arg = gen_send(arg.value())
  File "/home/pcp1/bonachea/UPC/upcxx/nobsrule.py", line 404, in execute
    mk = mk[mk.index(":")+1:]
ValueError: substring not found
1

However make no other change except shrinking the vertical size of your terminal window and when re-running the last lines instead become:

ValueError: substring not found
0

with the more common multi-page template errors, the exit code is almost always dropped.

This incorrect error code is also propagating to the result of the install script.

Comments (4)

  1. Former user Account Deleted

    Easy fix, but I'm curious as to what in your workflow is sensitive to this? If paging is active (no redirection happening) then I'm assuming its the top-level user at the prompt who usually doesn't care about the previous commands exit status ($?).

  2. Dan Bonachea reporter

    Thanks John.

    The nightly CI sets PAGER=cat exactly because it is not an interactive user, but it does care about the exit code as one way to detect failures. Although it's also redirecting output to a file, so perhaps this bug was not relevant there.

    The updates I made yesterday to the install script also use the exit code to print a final line of output after a nobs failure with instructions on submitting a bug report.

  3. Log in to comment