|
|
@ -439,29 +439,20 @@ void rl_callback(void *dummy, readline_curses *rc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case LNM_EXEC: {
|
|
|
|
case LNM_EXEC: {
|
|
|
|
char fn_template[PATH_MAX];
|
|
|
|
auto_mem<FILE> tmpout(fclose);
|
|
|
|
auto_mem<char> abspath;
|
|
|
|
|
|
|
|
auto_fd fd;
|
|
|
|
tmpout = std::tmpfile();
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(fn_template, sizeof(fn_template),
|
|
|
|
if (!tmpout) {
|
|
|
|
"/%s/lnav-script-out.XXXXXX",
|
|
|
|
|
|
|
|
getenv("TMPDIR"));
|
|
|
|
|
|
|
|
if ((fd = mkstemp(fn_template)) == -1) {
|
|
|
|
|
|
|
|
rc->set_value("Unable to open temporary output file: " + string(strerror(errno)));
|
|
|
|
rc->set_value("Unable to open temporary output file: " + string(strerror(errno)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((abspath = realpath(fn_template, NULL)) == NULL) {
|
|
|
|
|
|
|
|
rc->set_value("Unable to get real path to temporary file");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
auto_fd fd(fileno(tmpout));
|
|
|
|
auto_fd fd_copy((const auto_fd &) fd);
|
|
|
|
auto_fd fd_copy((const auto_fd &) fd);
|
|
|
|
char desc[256], timestamp[32];
|
|
|
|
char desc[256], timestamp[32];
|
|
|
|
time_t current_time = time(NULL);
|
|
|
|
time_t current_time = time(NULL);
|
|
|
|
string path_and_args = rc->get_value();
|
|
|
|
string path_and_args = rc->get_value();
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto_mem<FILE> tmpout(fclose);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((tmpout = fdopen(fd, "w+")) != NULL) {
|
|
|
|
|
|
|
|
lnav_data.ld_output_stack.push(tmpout);
|
|
|
|
lnav_data.ld_output_stack.push(tmpout);
|
|
|
|
string result = execute_file(ec, path_and_args);
|
|
|
|
string result = execute_file(ec, path_and_args);
|
|
|
|
string::size_type lf_index = result.find('\n');
|
|
|
|
string::size_type lf_index = result.find('\n');
|
|
|
@ -470,8 +461,6 @@ void rl_callback(void *dummy, readline_curses *rc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rc->set_value(result);
|
|
|
|
rc->set_value(result);
|
|
|
|
lnav_data.ld_output_stack.pop();
|
|
|
|
lnav_data.ld_output_stack.pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct stat st;
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
|
|
|
@ -493,8 +482,6 @@ void rl_callback(void *dummy, readline_curses *rc)
|
|
|
|
X, "to close the file"));
|
|
|
|
X, "to close the file"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
remove(abspath.in());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|