dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] shell: Enable fnmatch/glob by default
@ 2020-11-14 13:33 René Scharfe
  2020-11-16  2:47 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2020-11-14 13:33 UTC (permalink / raw)
  To: dash

Hello,

on Debian testing dash eats trailing slashes of parameters that happen
to be regular files when expanding "$@".  Example:

   $ rm -f foo bar
   $ touch foo
   $ dash -c 'echo "$0" "$@"' baz foo/ bar/ ./
   baz foo bar/ ./

So slashes after non-existing files and directories are kept.

This behavior was introduced by 7638476 (shell: Enable fnmatch/glob by
default, 2020-05-28).  Before this commit trailing slashes were kept
also for regular files:

   $ dash -c 'echo "$0" "$@"' baz foo/ bar/ ./
   baz foo/ bar/ ./

This feels like a bug to me: Intuitively, foo/ should not match a
regular file foo, so such a string should be kept as-is.

I noticed it today because Debian testing imported the current version
of dash and some tests of Git's internal test suite rely on trailing
slashes to be retained.

René

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] shell: Enable fnmatch/glob by default
  2020-11-14 13:33 [PATCH] shell: Enable fnmatch/glob by default René Scharfe
@ 2020-11-16  2:47 ` Herbert Xu
  2020-11-16  2:52   ` [PATCH] shell: Disable glob again as it strips traing slashes Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2020-11-16  2:47 UTC (permalink / raw)
  To: René Scharfe; +Cc: dash

René Scharfe <l.s.r@web.de> wrote:
> Hello,
> 
> on Debian testing dash eats trailing slashes of parameters that happen
> to be regular files when expanding "$@".  Example:
> 
>   $ rm -f foo bar
>   $ touch foo
>   $ dash -c 'echo "$0" "$@"' baz foo/ bar/ ./
>   baz foo bar/ ./

In fact you just have to do

	dash -c 'echo bar\/'

This is a bug in glob(3).  It's stripping the slash.

I guess we'll just have to disable glob again.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] shell: Disable glob again as it strips traing slashes
  2020-11-16  2:47 ` Herbert Xu
@ 2020-11-16  2:52   ` Herbert Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2020-11-16  2:52 UTC (permalink / raw)
  To: René Scharfe; +Cc: dash

On Mon, Nov 16, 2020 at 01:47:48PM +1100, Herbert Xu wrote:
> René Scharfe <l.s.r@web.de> wrote:
> > 
> > on Debian testing dash eats trailing slashes of parameters that happen
> > to be regular files when expanding "$@".  Example:
> > 
> >   $ rm -f foo bar
> >   $ touch foo
> >   $ dash -c 'echo "$0" "$@"' baz foo/ bar/ ./
> >   baz foo bar/ ./
> 
> In fact you just have to do
> 
> 	dash -c 'echo bar\/'
> 
> This is a bug in glob(3).  It's stripping the slash.
> 
> I guess we'll just have to disable glob again.

This patch disables glob(3) by default.

Reported-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/configure.ac b/configure.ac
index ab3c02e..e9ae792 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,8 +39,7 @@ fi
 
 AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--disable-fnmatch, \
 				      [Do not use fnmatch(3) from libc]))
-AC_ARG_ENABLE(glob, AS_HELP_STRING(--disable-glob, \
-				   [Do not use glob(3) from libc]))
+AC_ARG_ENABLE(glob, AS_HELP_STRING(--enable-glob, [Use glob(3) from libc]))
 
 dnl Checks for libraries.
 
@@ -128,7 +127,7 @@ if test "$enable_fnmatch" != no; then
 	AC_CHECK_FUNCS(fnmatch, use_fnmatch=yes)
 fi
 
-if test "$use_fnmatch" = yes && test "$enable_glob" != no; then
+if test "$use_fnmatch" = yes && test "$enable_glob" = yes; then
 	AC_CHECK_FUNCS(glob)
 fi
 
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-16  2:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-14 13:33 [PATCH] shell: Enable fnmatch/glob by default René Scharfe
2020-11-16  2:47 ` Herbert Xu
2020-11-16  2:52   ` [PATCH] shell: Disable glob again as it strips traing slashes Herbert Xu

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).