dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Aurelien Jarno <aurelien@aurel32.net>,
	976865@bugs.debian.org, andrew@shadura.me, dash@vger.kernel.org
Subject: Re: Bug#976865: Fwd: Bug#974900: dash removes trailing slash from script arguments
Date: Thu, 10 Dec 2020 10:20:29 -0500	[thread overview]
Message-ID: <X9I8vStSYdovXOIM@coredump.intra.peff.net> (raw)
In-Reply-To: <20201210113508.GA28224@gondor.apana.org.au>

On Thu, Dec 10, 2020 at 10:35:08PM +1100, Herbert Xu wrote:

> Yes but it's really a bug in glob(3).  It should really return
> a no-match for the case in question, rather than matching and then
> returning a filename without the slash.
> 
> IOW the pattern "foo\/" should not match a regular file foo.
> 
> Note that the problem doesn't occur for "foo/".

It seems like it happens for "foo/", too. If I compile:

-- >8 --
#include <glob.h>
#include <stdio.h>

int main(int argc, const char **argv)
{
	while (*++argv) {
		glob_t r;
		if (glob(*argv, 0, NULL, &r))
			perror(*argv);
		else {
			size_t i;
			for (i = 0; i < r.gl_pathc; i++)
				printf("%s -> %s\n", *argv, r.gl_pathv[i]);
			globfree(&r);
		}
	}
	return 0;
}
-- >8 --

I get:

  $ rm -f foo bar
  $ touch foo
  $ ./a.out foo foo/ 'foo\/' bar bar/ 'bar\/'
  foo -> foo
  foo/ -> foo
  foo\/ -> foo
  bar: No such file or directory
  bar/: No such file or directory
  bar\/: No such file or directory

-Peff

  reply	other threads:[~2020-12-10 15:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 10:30 Fwd: Bug#974900: dash removes trailing slash from script arguments Andrej Shadura
2020-11-17  3:32 ` Herbert Xu
2020-12-09 12:27   ` Aurelien Jarno
2020-12-10  2:56     ` Bug#976865: " Herbert Xu
2020-12-10  7:58       ` Aurelien Jarno
2020-12-10 11:35         ` Herbert Xu
2020-12-10 15:20           ` Jeff King [this message]
2020-12-11  2:03             ` Herbert Xu
2020-12-11  2:05               ` Jeff King
2020-12-12 21:18           ` Florian Weimer
2020-12-10 12:12     ` Herbert Xu

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X9I8vStSYdovXOIM@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=976865@bugs.debian.org \
    --cc=andrew@shadura.me \
    --cc=aurelien@aurel32.net \
    --cc=dash@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    /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 NNTP newsgroup(s).