From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Eli Zaretskii <eliz@gnu.org>
Subject: Re: Support GLOB_TILDE_CHECK for ~user in glob.c on MS-Windows
Date: Tue, 30 Mar 2021 02:50:53 +0200 [thread overview]
Message-ID: <4979476.qWmlisyi97@omega> (raw)
In-Reply-To: <837dlqmga7.fsf@gnu.org>
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
next prev parent reply other threads:[~2021-03-30 0:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 9:59 Support GLOB_TILDE_CHECK for ~user in glob.c on MS-Windows Eli Zaretskii
2021-03-30 0:50 ` Bruno Haible [this message]
2021-03-30 6:41 ` Eli Zaretskii
2021-04-02 15:35 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4979476.qWmlisyi97@omega \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).