diff -cr nano/files.c nano.mod/files.c *** nano/files.c Wed Mar 6 09:32:17 2002 --- nano.mod/files.c Sun Mar 10 20:13:03 2002 *************** *** 280,285 **** --- 280,312 ---- return 1; } + int open_pipe(char *command) + { + int forkpid, fd; + char pipefile[15]; + char *execute; + + execute = charalloc(strlen(command) + 24); + sprintf(pipefile,"/tmp/nano.%d",getpid()); + sprintf(execute,"%s 2>&1 > %s",command,pipefile); + umask(0); + mkfifo(pipefile,0700); + forkpid = fork(); + if (forkpid == -1) { + statusbar(_("Could not fork")); + return 1; + } + else if (forkpid == 0) { + execl("/bin/sh","/bin/sh","-c",execute,0); + exit(0); + } + fd = open(pipefile,O_RDONLY); + read_file(fd,"stdin",0); + free(execute); + unlink(pipefile); + return 0; + } + /* Open the file (and decide if it exists) */ int open_file(char *filename, int insert, int quiet) { *************** *** 427,433 **** } #endif ! i = open_file(realname, 1, loading_file); #ifdef ENABLE_MULTIBUFFER if (loading_file) --- 454,474 ---- } #endif ! if (i == NANO_END_KEY) { ! i = statusq(1, insertfile_list, "", _("Command to execute ")); ! if (i == -1) { ! statusbar(_("Cancelled")); ! UNSET(KEEP_CUTBUFFER); ! display_main_list(); ! return 0; ! } ! if (answer != NULL) { ! i = open_pipe(answer); ! } ! } ! else { ! i = open_file(realname, 1, loading_file); ! } #ifdef ENABLE_MULTIBUFFER if (loading_file) diff -cr nano/global.c nano.mod/global.c *** nano/global.c Sun Mar 3 16:36:36 2002 --- nano.mod/global.c Sun Mar 10 16:44:58 2002 *************** *** 268,274 **** #ifndef NANO_SMALL char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg = ! "", *nano_reverse_msg = ""; char *nano_dos_msg = "", *nano_mac_msg = ""; #ifdef HAVE_REGEX_H --- 268,274 ---- #ifndef NANO_SMALL char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg = ! "", *nano_reverse_msg = "", *nano_execute_msg = ""; char *nano_dos_msg = "", *nano_mac_msg = ""; #ifdef HAVE_REGEX_H *************** *** 317,322 **** --- 317,323 ---- nano_case_msg = _("Make the current search or replace case (in)sensitive"); nano_tofiles_msg = _("Go to file browser"); + nano_execute_msg = _("Execute external command"); nano_gotodir_msg = _("Goto Directory"); nano_cancel_msg = _("Cancel the current function"); nano_append_msg = _("Append to the current file"); *************** *** 638,643 **** --- 639,646 ---- sc_init_one(&insertfile_list, NANO_TOFILES_KEY, _("To Files"), nano_tofiles_msg, 0, 0, 0, NOVIEW, 0); #endif + sc_init_one(&insertfile_list, NANO_END_KEY, _("Execute Command"), + nano_execute_msg, 0, 0, 0, NOVIEW, 0); sc_init_one(&spell_list, NANO_HELP_KEY, _("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);