When running srfsh to process a script, do not log
the requests in .srfsh_history.
To test
-------
[1] Run the following command:
echo 'request opensrf.math opensrf.system.echo "foo"' | srfsh
[2] Note that the last line of ~/.srfsh_history should be
'request opensrf.math opensrf.system.echo "foo"'
[3] Apply the patch, compile, and run
echo 'request opensrf.math opensrf.system.echo "bar"' | srfsh
[4] This time, no additional line should have been added to
~/.srfsh_history
[5] Another variation to try:
srfsh test.srfsh
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
is_from_script = 1;
}
}
-
+
+ // if stdin is not a tty, assume that we're running
+ // a script and don't want to record history
+ if (!isatty(fileno(stdin))) is_from_script = 1;
+
/* --------------------------------------------- */
- load_history();
+ if (!is_from_script) load_history();
client = osrfSystemGetTransportClient();
osrfAppSessionSetIngress("srfsh");
}
process_request( cmd );
- if( request && *cmd ) {
+ if( !is_from_script && request && *cmd ) {
add_history(request);
}