bug-gnulib
[Top][All Lists]
Advanced

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

Re: Support GLOB_TILDE_CHECK for ~user in glob.c on MS-Windows


From: Bruno Haible
Subject: Re: Support GLOB_TILDE_CHECK for ~user in glob.c on MS-Windows
Date: Tue, 30 Mar 2021 02:50:53 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-203-generic; KDE/5.18.0; x86_64; ; )

Hi Eli,

> When Gnulib's glob.c is used on MS-Windows, tilde expansion in the
> likes of "~foo" always "succeeds", even when GLOB_TILDE_CHECK is set
> in the flags, although in this case 'glob' simply punts and returns
> the original unexpanded argument.  Suggested minimal patch is below:
> 
> --- glob.c~   2021-03-25 03:47:10.000000000 +0200
> +++ glob.c    2021-03-29 12:48:20.907625000 +0300
> @@ -881,7 +881,15 @@ __glob (const char *pattern, int flags, 
>                }
>              scratch_buffer_free (&pwtmpbuf);
>            }
> -#endif /* !WINDOWS32 */
> +#else  /* WINDOWS32 */
> +       /* We don't support ~USER on MS-Windows (FIXME: could have
> +          at least supported that if USER == $USERNAME).  */
> +       if (flags & GLOB_TILDE_CHECK)
> +         {
> +           retval = GLOB_NOMATCH;
> +           goto out;
> +         }
> +#endif /* WINDOWS32 */
>          }
>      }
>  

Your patch is consistent with the behaviour of this code on Unix,
when the user does not exist.

But would it not be possible to support the ~user syntax also on
Windows? By creating a gnulib module 'getpwnam' based on the
function GetUserProfileDirectory() [1][2] ?

Bruno

[1] 
https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getallusersprofiledirectorya
[2] 
https://stackoverflow.com/questions/19347916/how-do-i-find-a-profile-dir-of-a-windows-user-not-the-current-user-using-delph




reply via email to

[Prev in Thread] Current Thread [Next in Thread]