NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/54764: Incorrect '+file' filename completion in mail(1)



>Number:         54764
>Category:       bin
>Synopsis:       Incorrect '+file' filename completion in mail(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 14 20:20:00 +0000 2019
>Originator:     elo
>Release:        NetBSD 9.0_BETA
>Organization:
>Environment:
System: NetBSD marmite.localnet 9.0_BETA NetBSD 9.0_BETA (BLUEBELL) #3: Sun Nov 3 02:10:56 GMT 2019 elo@marmite.localnet:/usr/obj/sys/arch/amd64/compile/BLUEBELL amd64
Architecture: x86_64
Machine: amd64
>Description:
	If the 'folder' command of the mail(1) client program is
	provided the stem of a file argument employing the special
	'+file' naming convention, filename completion does not
	operate as expected. The initial '+' character indicates to
	the mail client that the filename to follow resides in the
	user's mail folder directory (if the user has defined such
	a directory), but the filename completion code treats the
	'+' as the first character of the filename, with no special
	significance.
>How-To-Repeat:
	Assume the current working directory has a file '+foo', and
	the user's mail folder directory contains an mbox file 'foo'.
	If the user enters the mail client command 'folder +fo', then
	requests filename completion, the file '+foo' in the working
	directory will be matched and expanded, not the file 'foo' in
	the folder directory. In my view, for the mail client to be
	self-consistent, it ought to be the other way round.
>Fix:
	Apply the following patch (or something like it). With this
	modification, if a mail folder directory has been defined and
	the filename stem provided to the 'folder' command begins
	with '+' and contains no '/' characters, filename completion
	will look for matches within the folder directory. To match a
	file elsewhere that has '+' as the first character, specify
	a relative or absolute path before the filename stem, e.g.,
	'folder ./+foo'.

--- a/usr/src/usr.bin/mail/complete.c	2019-12-14 13:12:21.684617910 +0000
+++ b/usr/src/usr.bin/mail/complete.c	2019-12-14 13:21:02.456628354 +0000
@@ -332,16 +332,27 @@
 {
 	StringList *words;
 	char dir[MAXPATHLEN];
-	char *fname;
+	char *fname, *mf;
 	DIR *dd;
 	struct dirent *dp;
 	unsigned char rv;
 	size_t len;

 	if ((fname = strrchr(word, '/')) == NULL) {
-		dir[0] = '.';
-		dir[1] = '\0';
-		fname = word;
+		if (word[0] == '+' && (mf = value(ENAME_FOLDER)) != NULL) {
+			if (mf[0] == '/') {
+				(void)estrlcpy(dir, mf, sizeof(dir));
+			} else {
+				dir[0] = '~';
+				dir[1] = '/';
+				(void)estrlcpy(dir + 2, mf, sizeof(dir) - 2);
+			}
+			fname = word + 1;
+		} else {
+			dir[0] = '.';
+			dir[1] = '\0';
+			fname = word;
+		}
 	} else {
 		if (fname == word) {
 			dir[0] = '/';



Home | Main Index | Thread Index | Old Index