Debian Bug report logs - #542430
[vim] vim try to expand files or directories that contain ~ (when using tcsh shell)

version graph

Package: vim; Maintainer for vim is Debian Vim Maintainers <[email protected]>; Source for vim is src:vim (PTS, buildd, popcon).

Reported by: gregory hainaut <[email protected]>

Date: Wed, 19 Aug 2009 16:00:03 UTC

Severity: normal

Tags: patch

Found in version vim/2:7.2.245-2

Forwarded to Bram Moolenaar <[email protected]>

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], Debian Vim Maintainers <[email protected]>:
Bug#542430; Package vim. (Wed, 19 Aug 2009 16:00:16 GMT) (full text, mbox, link).


Acknowledgement sent to gregory hainaut <[email protected]>:
New Bug report received and forwarded. Copy sent to Debian Vim Maintainers <[email protected]>. (Wed, 19 Aug 2009 16:00:17 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: gregory hainaut <[email protected]>
To: [email protected]
Subject: [vim] vim try to expand files or directories that contain ~ (when using tcsh shell)
Date: Wed, 19 Aug 2009 17:55:54 +0200
[Message part 1 (text/plain, inline)]
Package: vim
Version: 2:7.2.245-2
Severity: normal
Tags: patch

--- Please enter the report below this line. ---

Hi,

To reproduce the bug. Just create a directory with a ~ (mkdir
-p /tmp/bad~dir). Then when you do a ":chdir /tmp/bad~dir", an error
is raised "E79: Cannot expand wildcards". 
As a side effect it is not possible to use a tags file in the bad~dir
or below (/tmp/bad~dir/tags) because it will no be seen by vim.

Note I have not tested all shell but the bug appears with the tsch
shell (and not zsh for example). So you must use this option "set
shell=/bin/tcsh\ -f".

Please find attached a patch that seems solve the problem not sure it
is the good solution (and works in all situations). Maybe a solution
will be to escaped ~ like '\~' before sending to the tcsh shell.

Note: Tcsh debian version is 6.14.00-7 

Best Regards,
Gregory


--- System information. ---
Architecture: i386
Kernel:       Linux 2.6.30.3-ghost

Debian Release: squeeze/sid
  500 unstable        ftp.fr.debian.org 
    1 experimental    ftp.fr.debian.org 

--- Package information. ---
Depends                   (Version) | Installed
===================================-+-====================
vim-common        (= 2:7.2.245-2)   | 2:7.2.245-2
vim-runtime       (= 2:7.2.245-2)   | 2:7.2.245-2
libacl1               (>= 2.2.11-1) | 2.2.47-3
libc6                    (>= 2.3.4) | 2.9-25
libgpm2                 (>= 1.20.4) | 1.20.4-3.2
libncurses5     (>= 5.6+20071006-3) | 5.7+20090803-1+b1
libselinux1             (>= 2.0.85) | 2.0.85-1


Package's Recommends field is empty.

Suggests         (Version) | Installed
==========================-+-===========
ctags                      | 
vim-doc                    | 
vim-scripts                | 20090211-1





[fix_expansion.patch (text/x-patch, attachment)]

Information forwarded to [email protected], Debian Vim Maintainers <[email protected]>:
Bug#542430; Package vim. (Thu, 20 Aug 2009 14:30:09 GMT) (full text, mbox, link).


Acknowledgement sent to James Vega <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Vim Maintainers <[email protected]>. (Thu, 20 Aug 2009 14:30:09 GMT) (full text, mbox, link).


Message #10 received at [email protected] (full text, mbox, reply):

From: James Vega <[email protected]>
To: gregory hainaut <[email protected]>, [email protected]
Subject: Re: Bug#542430: [vim] vim try to expand files or directories that contain ~ (when using tcsh shell)
Date: Thu, 20 Aug 2009 10:28:23 -0400
[Message part 1 (text/plain, inline)]
On Wed, Aug 19, 2009 at 05:55:54PM +0200, gregory hainaut wrote:
> Please find attached a patch that seems solve the problem not sure it
> is the good solution (and works in all situations). Maybe a solution
> will be to escaped ~ like '\~' before sending to the tcsh shell.

This looks good to me.  I'll forward it upstream and see what he thinks.
Thanks for the patch. :)

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[email protected]>
[signature.asc (application/pgp-signature, inline)]

Information forwarded to [email protected], Debian Vim Maintainers <[email protected]>:
Bug#542430; Package vim. (Tue, 03 Nov 2009 21:03:12 GMT) (full text, mbox, link).


Acknowledgement sent to James Vega <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Vim Maintainers <[email protected]>. (Tue, 03 Nov 2009 21:03:12 GMT) (full text, mbox, link).


Message #15 received at [email protected] (full text, mbox, reply):

From: James Vega <[email protected]>
To: gregory hainaut <[email protected]>, [email protected]
Subject: Re: Bug#542430: [vim] vim try to expand files or directories that contain ~ (when using tcsh shell)
Date: Tue, 3 Nov 2009 15:52:44 -0500
On Thu, Aug 20, 2009 at 9:28 AM, James Vega <[email protected]> wrote:
> On Wed, Aug 19, 2009 at 05:55:54PM +0200, gregory hainaut wrote:
>> Please find attached a patch that seems solve the problem not sure it
>> is the good solution (and works in all situations). Maybe a solution
>> will be to escaped ~ like '\~' before sending to the tcsh shell.
>
> This looks good to me.  I'll forward it upstream and see what he thinks.
> Thanks for the patch. :)

Looking into this further, this isn't actually a problem with using tcsh
or the expansion of '~'.  The problem is what that Vim isn't properly
detecting which shell you're using because you've set 'shell' to
"/bin/tcsh -f" instead of simply "/bin/tcsh".

In src/os_unix.c

5354     else if ((len = STRLEN(p_sh)) >= 3)
5355     {
5356         if (STRCMP(p_sh + len - 3, "csh") == 0)
5357             shell_style = STYLE_GLOB;

Vim checks whether the last 3 characters of 'shell' are "csh".  Since
that fails with your setting, Vim then uses an sh-compatible method for
expansion.  This obviously fails with tcsh.

So, the simple workaround for now is to simply "set shell=/bin/tcsh".
I'll send this information to Bram so he knows about it.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[email protected]>




Information forwarded to [email protected], Debian Vim Maintainers <[email protected]>:
Bug#542430; Package vim. (Tue, 03 Nov 2009 21:30:20 GMT) (full text, mbox, link).


Acknowledgement sent to James Vega <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Vim Maintainers <[email protected]>. (Tue, 03 Nov 2009 21:30:20 GMT) (full text, mbox, link).


Message #20 received at [email protected] (full text, mbox, reply):

From: James Vega <[email protected]>
To: Bram Moolenaar <[email protected]>
Cc: [email protected], [email protected]
Subject: Incorrect wildcard expansion when p_sh has arguments to the shell
Date: Tue, 3 Nov 2009 16:12:43 -0500
Bram,

The code in src/os_unix.c:mch_expand_wildcards which detects what shell
is being used doesn't work properly if 'shell' has been set to a shell
and arguments (e.g., "/bin/tcsh -f").

5354     else if ((len = STRLEN(p_sh)) >= 3)
5355     {
5356         if (STRCMP(p_sh + len - 3, "csh") == 0)
5357             shell_style = STYLE_GLOB;
5358         else if (STRCMP(p_sh + len - 3, "zsh") == 0)
5359             shell_style = STYLE_PRINT;
5360     }
5361     if (shell_style == STYLE_ECHO && strstr((char *)gettail(p_sh),
5362
"sh") != NULL)
5363         shell_style = STYLE_VIMGLOB;

Vim checks whether the last 3 characters of 'shell' are "csh".  Since
the last 3 characters of p_sh in this case are " -f", Vim then checks
whether "sh" is in gettail(p_sh) and uses sh-compatible shell expansion.

It looks like a safer approach would be to grab p_sh up to the first
whitespace and then use gettail() on that to get the shell name.  That
should reduce the false-positive rate for setting STYLE_VIMGLOB in line
5363.

Although, it'll still fail with shells like fish which will pass the
strstr(..., "sh") check but not work with STYLE_VIMGLOB.  fish does work
with STYLE_ECHO, so we could add that to the special-case list.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[email protected]>




Reply sent to James Vega <[email protected]>:
You have marked Bug as forwarded. (Tue, 03 Nov 2009 21:30:34 GMT) (full text, mbox, link).


Information forwarded to [email protected], Debian Vim Maintainers <[email protected]>:
Bug#542430; Package vim. (Tue, 03 Nov 2009 22:06:06 GMT) (full text, mbox, link).


Acknowledgement sent to Bram Moolenaar <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Vim Maintainers <[email protected]>. (Tue, 03 Nov 2009 22:06:07 GMT) (full text, mbox, link).


Message #28 received at [email protected] (full text, mbox, reply):

From: Bram Moolenaar <[email protected]>
To: James Vega <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: Incorrect wildcard expansion when p_sh has arguments to the shell
Date: Tue, 03 Nov 2009 22:52:28 +0100
James -

> The code in src/os_unix.c:mch_expand_wildcards which detects what shell
> is being used doesn't work properly if 'shell' has been set to a shell
> and arguments (e.g., "/bin/tcsh -f").
> 
> 5354     else if ((len = STRLEN(p_sh)) >= 3)
> 5355     {
> 5356         if (STRCMP(p_sh + len - 3, "csh") == 0)
> 5357             shell_style = STYLE_GLOB;
> 5358         else if (STRCMP(p_sh + len - 3, "zsh") == 0)
> 5359             shell_style = STYLE_PRINT;
> 5360     }
> 5361     if (shell_style == STYLE_ECHO && strstr((char *)gettail(p_sh),
> 5362
> "sh") != NULL)
> 5363         shell_style = STYLE_VIMGLOB;
> 
> Vim checks whether the last 3 characters of 'shell' are "csh".  Since
> the last 3 characters of p_sh in this case are " -f", Vim then checks
> whether "sh" is in gettail(p_sh) and uses sh-compatible shell expansion.
> 
> It looks like a safer approach would be to grab p_sh up to the first
> whitespace and then use gettail() on that to get the shell name.  That
> should reduce the false-positive rate for setting STYLE_VIMGLOB in line
> 5363.
> 
> Although, it'll still fail with shells like fish which will pass the
> strstr(..., "sh") check but not work with STYLE_VIMGLOB.  fish does work
> with STYLE_ECHO, so we could add that to the special-case list.

Well, theoretically there could be a space in the path.  I think
searching for the last slash, using gettail(), can comparing from that
position should work in most cases.  To catch "tcsh" as well as "csh" we
can use "strstr" on gettail().  That only fails for "sh -csh", but
that's unlikely to be used :-).

-- 
Any sufficiently advanced technology is indistinguishable from magic.
					Arthur C. Clarke
Any sufficiently advanced bug is indistinguishable from a feature.
                                        Rich Kulawiec

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///




Information forwarded to [email protected], Debian Vim Maintainers <[email protected]>:
Bug#542430; Package vim. (Tue, 03 Nov 2009 23:00:13 GMT) (full text, mbox, link).


Acknowledgement sent to James Vega <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Vim Maintainers <[email protected]>. (Tue, 03 Nov 2009 23:00:13 GMT) (full text, mbox, link).


Message #34 received at [email protected] (full text, mbox, reply):

From: James Vega <[email protected]>
To: Bram Moolenaar <[email protected]>
Cc: [email protected]
Subject: Re: Incorrect wildcard expansion when p_sh has arguments to the shell
Date: Tue, 3 Nov 2009 17:44:22 -0500
[Message part 1 (text/plain, inline)]
On Tue, Nov 03, 2009 at 10:52:28PM +0100, Bram Moolenaar wrote:
> 
> James -
> 
> > The code in src/os_unix.c:mch_expand_wildcards which detects what shell
> > is being used doesn't work properly if 'shell' has been set to a shell
> > and arguments (e.g., "/bin/tcsh -f").
> > 
> > 5354     else if ((len = STRLEN(p_sh)) >= 3)
> > 5355     {
> > 5356         if (STRCMP(p_sh + len - 3, "csh") == 0)
> > 5357             shell_style = STYLE_GLOB;
> > 5358         else if (STRCMP(p_sh + len - 3, "zsh") == 0)
> > 5359             shell_style = STYLE_PRINT;
> > 5360     }
> > 5361     if (shell_style == STYLE_ECHO && strstr((char *)gettail(p_sh),
> > 5362
> > "sh") != NULL)
> > 5363         shell_style = STYLE_VIMGLOB;
> > 
> > Vim checks whether the last 3 characters of 'shell' are "csh".  Since
> > the last 3 characters of p_sh in this case are " -f", Vim then checks
> > whether "sh" is in gettail(p_sh) and uses sh-compatible shell expansion.
> > 
> > It looks like a safer approach would be to grab p_sh up to the first
> > whitespace and then use gettail() on that to get the shell name.  That
> > should reduce the false-positive rate for setting STYLE_VIMGLOB in line
> > 5363.
> > 
> > Although, it'll still fail with shells like fish which will pass the
> > strstr(..., "sh") check but not work with STYLE_VIMGLOB.  fish does work
> > with STYLE_ECHO, so we could add that to the special-case list.
> 
> Well, theoretically there could be a space in the path.

I thought of that, but I figured that was quite unlikely to happen on
unix systems.

> I think
> searching for the last slash, using gettail(), can comparing from that
> position should work in most cases.

That was my original idea, but that fails if the arguments after the
shell contain slashes.  Then again, that may be just as uncommon as
having spaces in the path.

> To catch "tcsh" as well as "csh" we can use "strstr" on gettail().

The current method of detecting (t)csh works fine. It's just that the
string being used to do the detection contains too much information.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[email protected]>
[signature.asc (application/pgp-signature, inline)]

Information forwarded to [email protected], Debian Vim Maintainers <[email protected]>:
Bug#542430; Package vim. (Tue, 19 Aug 2014 20:15:08 GMT) (full text, mbox, link).


Acknowledgement sent to Jethro Stuut <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Vim Maintainers <[email protected]>. (Tue, 19 Aug 2014 20:15:08 GMT) (full text, mbox, link).


Message #39 received at [email protected] (full text, mbox, reply):

From: Jethro Stuut <[email protected]>
To: [email protected]
Subject: Re: [vim] vim try to expand files or directories that contain ~ (when
Date: Tue, 19 Aug 2014 13:10:51 -0700
[Message part 1 (text/plain, inline)]
Date: Wed, 19 Aug 2009 17:55:54 +0200
>From: gregory hainaut <[email protected]>
>-------------
>Body: Package: vim
>Version: 2:7.2.245-2
>Severity: normal
>Tags: patch
>
>--- Please enter the report below this line. ---
>
>Hi,
>
>To reproduce the bug. Just create a directory with a ~ (mkdir
>-p /tmp/bad~dir). Then when you do a ":chdir /tmp/bad~dir", an error
>is raised "E79: Cannot expand wildcards".
>As a side effect it is not possible to use a tags file in the bad~dir
>or below (/tmp/bad~dir/tags) because it will no be seen by vim.
>
>Note I have not tested all shell but the bug appears with the tsch
>shell (and not zsh for example). So you must use this option "set
>shell=/bin/tcsh\ -f".
>
>Please find attached a patch that seems solve the problem not sure it
>is the good solution (and works in all situations). Maybe a solution
>will be to escaped ~ like '\~' before sending to the tcsh shell.
>
>Note: Tcsh debian version is 6.14.00-7
>
>Best Regards,
>Gregory
>
>
>--- System information. ---
>Architecture: i386
>Kernel:       Linux 2.6.30.3-ghost
>
>Debian Release: squeeze/sid
>  500 unstable        ftp.fr.debian.org
>    1 experimental    ftp.fr.debian.org
>
>--- Package information. ---
>Depends                   (Version) | Installed
>===================================-+-====================
>vim-common        (= 2:7.2.245-2)   | 2:7.2.245-2
>vim-runtime       (= 2:7.2.245-2)   | 2:7.2.245-2
>libacl1               (>= 2.2.11-1) | 2.2.47-3
>libc6                    (>= 2.3.4) | 2.9-25
>libgpm2                 (>= 1.20.4) | 1.20.4-3.2
>libncurses5     (>= 5.6+20071006-3) | 5.7+20090803-1+b1
>libselinux1             (>= 2.0.85) | 2.0.85-1
>
>
>Package's Recommends field is empty.
>
>Suggests         (Version) | Installed
>==========================-+-===========
>ctags                      |
>vim-doc                    |
>vim-scripts                | 20090211-1
[Message part 2 (text/html, inline)]

Information forwarded to [email protected], Debian Vim Maintainers <[email protected]>:
Bug#542430; Package vim. (Sun, 28 Mar 2021 12:30:27 GMT) (full text, mbox, link).


Acknowledgement sent to [email protected]:
Extra info received and forwarded to list. Copy sent to Debian Vim Maintainers <[email protected]>. (Sun, 28 Mar 2021 12:30:27 GMT) (full text, mbox, link).


Message #44 received at [email protected] (full text, mbox, reply):

From: Jerry Kloubarly Ngessan <[email protected]>
To: undisclosed-recipients:;
Subject: Mr.Jerry Kloubarly Ngessan
Date: Sun, 28 Mar 2021 12:29:49 +0000
Hello Please
I am Mr. Jerry Kloubarly Ngessan, I stopped at your email from our
international business directory in my research for a reliable person
to partner with, I have a business that will profit us both that I
want us to discuss. You can contact me for more details for convenient
business discussion if you are interested.
My email is   ([email protected])  I will be glad to
hear from you soon for more  details
Thanks for your time and waiting for your response
Mr.Jerry Kloubarly Ngessan



Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 12:45:11 2025; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.