LP#1461625: ensure srfsh doesn't close STDOUT prematurely
authorGalen Charlton <gmc@esilibrary.com>
Wed, 3 Jun 2015 17:42:06 +0000 (17:42 +0000)
committerMike Rylander <mrylander@gmail.com>
Wed, 24 Jun 2015 13:44:04 +0000 (09:44 -0400)
Ensure that when running srfsh in non-interactive mode
that reads commands directly from a file, (i.e.,
"srfsh script.srfsh" or as a shebang script), it does
not close STDOUT after handling the first request.

To test
-------
[1] Create a srfsh script containing:

    request opensrf.math opensrf.system.echo "foo"
    request opensrf.math opensrf.system.echo "bar"

[2] Run "srfsh script.srfsh". Note that only the
    results of the first echo request are output.
[3] Apply the patch and recompile, then run
    "srfsh script.srfsh" again.  This time, the
    output of both requests is displayed.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
src/srfsh/srfsh.c

index 753180b..a383492 100644 (file)
@@ -918,7 +918,7 @@ int send_request( const char* server,
        fprintf(less, "Request Time in seconds: %.6f\n", end - start );
        fputs("------------------------------------\n", less);
 
        fprintf(less, "Request Time in seconds: %.6f\n", end - start );
        fputs("------------------------------------\n", less);
 
-       pclose(less);
+       if(!is_from_script) pclose(less);
 
        osrf_app_session_request_finish( session, req_id );
 
 
        osrf_app_session_request_finish( session, req_id );