Re: using --noread with a named pipe

Benno Schulenberg <[email protected]>
Newsgroups gmane.editors.nano.general
Message-ID <[email protected]>
Op 14-01-18 om 19:52 schreef MikiStrange:
> What I am trying to do is to encrypt the contents of Nano without them being 
> written to disk at any point before the encryption process begins. When I
> read the explanation of -n --noread it said that the use for this option is to
> pipe to a named pipe.
Indeed.  And I broke that three years ago.  :|  With this commit:

     http://git.savannah.gnu.org/cgit/nano.git/commit/?id=98ffb642


The bug has been rereported as https://savannah.gnu.org/bugs/?52896.

Attached patch should fix it.  (It should apply cleanly to 2.9.2, or
really any version since 2.4.3.)  If you could test...

Benno

_______________________________________________
Help-nano mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-nano
0001-startup-allow-a-named-pipe-as-file-argument-when-nor.patch (text/x-patch, 977 B)
From 459868c2580930824ef71666d2ad54d26a737bb2 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <[email protected]>
Date: Mon, 15 Jan 2018 11:15:05 +0100
Subject: [PATCH] startup: allow a named pipe as file argument when --noread is
 used

This fixes https://savannah.gnu.org/bugs/?52896.
Reported-by: Miki Strange <[email protected]>
---
 src/files.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/files.c b/src/files.c
index fd02814c..b77d6779 100644
--- a/src/files.c
+++ b/src/files.c
@@ -435,7 +435,8 @@ bool open_buffer(const char *filename, bool undoable)
 	if (strcmp(filename, "") != 0) {
 		struct stat fileinfo;
 
-		if (stat(realname, &fileinfo) == 0 && !S_ISREG(fileinfo.st_mode)) {
+		if (stat(realname, &fileinfo) == 0 && !(S_ISREG(fileinfo.st_mode) ||
+					(ISSET(NOREAD_MODE) && S_ISFIFO(fileinfo.st_mode)))) {
 			if (S_ISDIR(fileinfo.st_mode))
 				statusline(ALERT, _("\"%s\" is a directory"), realname);
 			else
-- 
2.14.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.