Trevor Cordes) (68) [FIXED].
- Home and End control keys (^A, ^E) do not always work in filename
prompt (bug found by Ian Turner) (69) [1.0 series only] [FIXED].
+- Trying to insert a file of 0 bytes will hang nano (70) [FIXED].
** Open BUGS **
$Id$
- General
- Type misalignments and mem leaks in renumber_all, do_justify
and do_spell (Rocco & Steven Kneizys).
+ - New "External Command" code, originally by Dwayne Rightler.
+ New function files.c:open_pipe(), changes to do_insertfile(),
+ new list extcmd_list, cmd is ^X after ^R by default.
- files.c:
check_writable_directory()
- Stat full_path, not path (Steven Kneizys).
+ read_file()
+ - Abort if we read a file of 0 lines (num_lines == 0), fixes BUG #70.
- nano.c:
help_init()
- Capitalize Meta altkeys.
num_lines++;
buf[0] = 0;
}
- /* Did we even GET a file? */
+
+ /* Did we try to insert a file of 0 bytes? */
+ if (num_lines == 0)
+ {
+ statusbar(_("Read %d lines"), 0);
+ return 1;
+ }
+
+ /* Did we even GET a file if we don't already have one? */
if (totsize == 0 || fileptr == NULL) {
new_file();
statusbar(_("Read %d lines"), num_lines);
return 1;
}
+#ifndef NANO_SMALL
+int open_pipe(char *command)
+{
+ int forkpid, fd;
+ char *pipefile, *execute;
+
+ execute = charalloc(strlen(command) + 24);
+ if ((pipefile = safe_tempnam(0, "nano.")) == NULL) {
+ statusbar(_("Could not create a temporary filename: %s"),
+ strerror(errno));
+ free(execute);
+ free(pipefile);
+ return 1;
+ }
+
+ sprintf(execute,"%s 2>&1 > %s",command,pipefile);
+ umask(0);
+ mkfifo(pipefile,0700);
+ forkpid = fork();
+ if (forkpid == -1) {
+ statusbar(_("Could not fork"));
+ free(execute);
+ free(pipefile);
+ 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);
+ unlink(pipefile);
+ free(execute);
+ free(pipefile);
+ set_modified();
+ return 0;
+}
+#endif /* NANO_SMALL */
+
/* Open the file (and decide if it exists) */
int open_file(char *filename, int insert, int quiet)
{
}
#endif
- i = open_file(realname, 1, loading_file);
+#ifndef NANO_SMALL
+ if (i == NANO_EXTCMD_KEY) {
+ i = statusq(1, extcmd_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
+#endif /* NANO_SMALL */
+ {
+ i = open_file(realname, 1, loading_file);
+ }
#ifdef ENABLE_MULTIBUFFER
if (loading_file)
shortcut *insertfile_list = NULL;
shortcut *help_list = NULL;
shortcut *spell_list = NULL;
+shortcut *extcmd_list = NULL;
#ifndef DISABLE_BROWSER
shortcut *browser_list = NULL;
#endif
#ifndef NANO_SMALL
char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg =
- "", *nano_reverse_msg = "";
+ "", *nano_reverse_msg = "", *nano_execute_msg = "";
char *nano_dos_msg = "", *nano_mac_msg = "";
#ifdef HAVE_REGEX_H
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");
sc_init_one(&insertfile_list, NANO_TOFILES_KEY, _("To Files"),
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
#endif
+#ifndef NANO_SMALL
+ sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"),
+ nano_execute_msg, 0, 0, 0, NOVIEW, 0);
+#endif
sc_init_one(&spell_list, NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
sc_init_one(&spell_list, NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
+#ifndef NANO_SMALL
+ sc_init_one(&extcmd_list, NANO_HELP_KEY,
+ _("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
+
+ sc_init_one(&extcmd_list, NANO_CANCEL_KEY, _("Cancel"),
+ nano_cancel_msg, 0, 0, 0, VIEW, 0);
+#endif
#ifndef DISABLE_BROWSER
"instance of the given misspelled word in the "
"current file.\n\n The following other functions are "
"available in Spell Check mode:\n\n");
+#ifndef NANO_SMALL
+ else if (currshortcut == extcmd_list)
+ ptr = _("External Command Help Text\n\n "
+ "This menu allows you to insert the output of a command "
+ "run by the shell into the current buffer (or a new "
+ "buffer in multibuffer mode).\n\n The following keys are "
+ "available in this mode:\n\n");
+#endif
else /* Default to the main help list */
ptr = help_text_init;
#define NANO_OPENPREV_ALTKEY NANO_ALT_COMMA
#define NANO_OPENNEXT_ALTKEY NANO_ALT_PERIOD
#define NANO_BRACKET_KEY NANO_ALT_BRACKET
+#define NANO_EXTCMD_KEY NANO_CONTROL_X
#define TOGGLE_CONST_KEY NANO_ALT_C
#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I
extern shortcut *main_list, *whereis_list;
extern shortcut *replace_list, *goto_list;
extern shortcut *writefile_list, *insertfile_list;
-extern shortcut *spell_list, *replace_list_2;
+extern shortcut *spell_list, *replace_list_2, *extcmd_list;
extern shortcut *help_list;
#ifndef DISABLE_BROWSER
extern shortcut *browser_list, *gotodir_list;