Re: Tilde expansion in mkdir dialog



On Fri, 28 Nov 2003, David Sterba wrote:

> Hi,
>
> the new tilde expansion behaviour seems a bit ambiguous in make dir
> dialog (F7).
>
> I would like to create directory named '~', but this gets expanded to my
> home directory, which exist.

This command has always been using input_expand_dialog().  The same
behavior exists in version 4.6.0.  I believe there is no regression here.

> Now, I would like to create /home/mylogin/dir and input '~/dir' and here
> i want the expansion.
>
> Creation of '~' should be treated differently.
>
> (Well, I don't create directories '~' every day.)

Then we would need some way to quote the tilde.

> There is a bug in tilde expansion function:
> 1. try to create directory '~nonexistent'
> 2. shis should stay as-is, so I expect creation
>    of directory' ~nonexistent'
> 3. but only the directory 'nonexistent' is created

> Variable holding the directory name skips initial '~'
> but does not restore it back when returning nonexistent
> entry in passwd.
>
> patch:
> --- utilunix.c.orig     Fri Nov 28 11:45:57 2003
> +++ utilunix.c  Fri Nov 28 11:46:03 2003
> @@ -290,7 +290,7 @@
>
>      /* If we can't figure the user name, leave tilde unexpanded */
>      if (!passwd)
> -       return g_strdup (directory);
> +       return g_strdup (directory-1);
>
>      return g_strconcat (passwd->pw_dir, PATH_SEP_STR, p, NULL);
>  }

Yes, that's a new bug.  I have fixed it slightly differently.  The
variable "directory" should not have been used as a temporary string
pointer.  Nice example of code that is dangerous to change.

-- 
Regards,
Pavel Roskin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]