www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/09/02/16:20:26

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:from:to:references:in-reply-to
:subject:date:mime-version:content-type; q=dns; s=default; b=NkO
8C7IIp90VKwKiriarz5f2FNxmU1oGrbonXr1OrnClyDU+ZFM/J3Y3WTIw9xoAh5b
WjJz4vbP2z1oi+dJz37HgrqSBWR1Uwbt/y7+zPOpBF4HsoEW7Kp60ANvXrOSzoRu
85hzNf1KpUK5fCigxr2HslgGXfpWweRC0gccvQXc=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:from:to:references:in-reply-to
:subject:date:mime-version:content-type; s=default; bh=lmKiY5tJg
yZJZRb8dPkjZuZSFCE=; b=e0NTIT1mIw6E1lLDBFPMwLBqPSaUVGe5EZdjexLnl
mj7JSVdXciZEcHTAh6AwlQLxKDKtqGZ8ya34W1z2wBVbBJkHgROIo0HOkOFZrGut
BgirTjqmSAoMM85yvQpUJ3mPZgXz8RqaXUe3F5ZOeqxkyTSHfdkwjrTqlWmV+WLo
HY=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=H*x:16.4.3528.331, H*UA:16.4.3528.331, HX-MimeOLE:V16.4.3528.331, sja
X-HELO: mail-it0-f51.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:references:in-reply-to :subject:date:mime-version:importance; bh=aTAfR37V34PgOI8cgHOoINp5/lEFvURgwPmYL2xPa5M=; b=XQLTS2XI+s0w1+6WVEmXiDg7GvE78z/sVB4XRrgYlHj5QwGwxChTEyho4q6wGv7Lz6 sKzjJf4h518m5OmzJFb1GP/2yYt+QkN1mpfy3+tEO409v6gPi9pbg17nnoHVyKtTrVZ6 jzr5yY3WOmayiSavFWqbyrVMjy4dt/hpz+NqNU0bDvfsSc2WsJHaJpMqbKQ+O4JYOxIW e83jz95cLNjWWhJ2w3CkRCYWPipprxrvXcCpz8fbHRcMJNMd2HgVN5Dg36/f6F3dt6Cn oODISVUcrrMIJb3Xt6/TPZGGFkrRWJ1G/T6aVFcUDl6Z/Ld0XnhNzTO/bBhQWfmE49B2 dX6A==
X-Gm-Message-State: AE9vXwPyKY2bOKPuhhV3CwQR4KRDlVaC8r+8S1n8PTutFXQ3zptWTwF1xoC9l741+pH8Zg==
X-Received: by 10.107.139.195 with SMTP id n186mr1224119iod.185.1472847594469; Fri, 02 Sep 2016 13:19:54 -0700 (PDT)
Message-ID: <D6D912CDA2774E2FB30CA02A2B9467D1@skywavemobile.com>
From: "Stephen Anderson" <stephen DOT rhoderson AT gmail DOT com>
To: <cygwin AT cygwin DOT com>, "cyg Simple" <cygsimple AT gmail DOT com>
References: <FDF650EB6B144CDE9983FC655ABFF5FA AT skywavemobile DOT com> <9c8c94a1-2df6-354e-12ed-55d9d19670ca AT gmail DOT com>
In-Reply-To: <9c8c94a1-2df6-354e-12ed-55d9d19670ca@gmail.com>
Subject: Re: unzip, find broken by auto handling of .exe file extension
Date: Fri, 2 Sep 2016 16:19:52 -0400
MIME-Version: 1.0
X-IsSubscribed: yes

------=_NextPart_000_000A_01D20535.D5D24AE0
Content-Type: text/plain;
	format=flowed;
	charset="Windows-1252";
	reply-type=original
Content-Transfer-Encoding: 7bit

Thanks for looking at the problem.
Unfortunately not resolved...

1. As demonstrated by the provided ruby test case, it is very possible to 
have a directory and base filename be the same. Open bash and try it.

$ mkdir mything
$ touch mything.exe
$ ls mything*
mything.exe

mything:
$

2. Even if cygwin somehow prevented it (it can't), zip archives do not 
preclude the presence of a base filename with exe extension and same 
directory name.

3. The problem is not simply exe - batch files (.bat, .cmd), powershell 
(.ps1) and others are automatically picked up by cmd.exe processing, and can 
all have common base names.

4. I tried unzip -x and it does not workaround the problem. 7z remains my 
workaround and the only one I have found so far.

5. Terminating the find -path with / results in 'find: warning: -path 
testAutoExeExpansion/test/ will not match anything because it ends with /'.

6. Terminating the target with / does not help.

7. Rmdir fails with 'directory not empty'.

8. I am NOT trying to run the executable, so the globbing should NOT 
automatically be expanding 'test' to match 'test.exe'.
I would think that the only utilities that really should do that would be 
'which', 'whereis' or shell command completion (not file completion).

Attached updated test case.

sja

-----Original Message----- 
From: cyg Simple
Sent: Friday, September 02, 2016 2:40 PM
To: cygwin AT cygwin DOT com
Subject: Re: unzip, find broken by auto handling of .exe file extension

On 9/1/2016 12:00 PM, Stephen Anderson wrote:
> I am in the process of importing zip archive contents into an SVN repo
> and have encountered problems when unzip-6.00 expands an archive
> containing an executable file in a directory that contains a
> subdirectory with the same base name as the executable. If the
> executable happens to occur after the subdirectory, unzip works, however
> if the executable is first, unzip fails with the error:
>
> checkdir error:  testAutoExeExpansion/test exists but is not directory
>                 unable to process testAutoExeExpansion/test/.
>

How can a directory and a file of the same name exist?  It can't and
because Cygwin stats the foo.exe to be foo then that is the filename
comparison.

> Luckily I am able to use 7z extract, which does not exhibit the unzip
> problem and even allows me to exclude the culprit subdirectory (which
> luckily contains nothing I am interested in).
>

Unzip has the -x option to exclude archive items.

> In the process of trying to solve this problem, I used find-4.6.0 to try
> and delete the subdirectory after extracting with 7z to no avail.
> Even preceding the path match with a type directory spec find gets
> confused (so did the svn commit BTW).
>

Did you trail the name with / for the delete?  The rmdir command should
work. You would use the -exec option with find to execute rmdir rather
than the delete function of find.

> The enclosed ruby unit test reproduces the minimal circumstances of the
> issue for both unzip and find.
> It is likely that this is a common problem somewhere in the bowels of
> file 'globbing' in cygwin only.
>

Yes and one that allows the stat of foo.exe by foo only so that it can
launch the application.  It has existed since the beginning of Cygwin
and I doubt it will ever be resolved without requiring the full file
name for executables.

-- 
cyg Simple

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

------=_NextPart_000_000A_01D20535.D5D24AE0
Content-Type: application/octet-stream;
	name="Test_ExeAutoExpand.rb"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="Test_ExeAutoExpand.rb"

#!/usr/bin/ruby=0A=
# $URL: http://localhost:8008/svn/Research/CygwinAutoexeExpansionProblem/Te=
st_ExeAutoExpand.rb $=20=0A=
# $Revision: 74 $=0A=
# $Date: 2016-09-02 14:49:50 -0400 (Fri, 02 Sep 2016) $=0A=
# $Author: stephen_a $=0A=
require 'minitest/autorun'=0A=
require 'fileutils'=20=0A=
=0A=
# Lots of straight-forward tests, success path only.=0A=
class Test_ExeAutoExpand < Minitest::Test=0A=
=20=20=0A=
  # Prepare common stuff for test execution.=0A=
  def setup=0A=
    # Create a hierarchy like this:=0A=
    # testAutoExeExpansion=0A=
    #    |=0A=
    #    - test.exe=0A=
    #    + test/=0A=
    #        |=0A=
    #        - test.exe=0A=
    #=0A=
    %x(rm -rf testAutoExeExpansion*)=0A=
    %x(mkdir -p testAutoExeExpansion)=0A=
    %x(mkdir -p testAutoExeExpansion/test)=0A=
    %x(touch testAutoExeExpansion/test.exe)=0A=
    %x(touch testAutoExeExpansion/test/test.exe)=0A=
  end=0A=
=0A=
  # Do common stuff to wrap up tests.=0A=
  def teardown=0A=
  end=0A=
=0A=
  # Check that zip/unzip with default ordering works=0A=
  # The default ordering puts directory first and seems=0A=
  # to cause no problems.=0A=
  def test_unzipDefault=0A=
    %x(zip -r testAutoExeExpansion.zip testAutoExeExpansion)=0A=
    assert_equal(0, $?.exitstatus, "zip failed!")=0A=
    %x(rm -r testAutoExeExpansion/)=0A=
    %x(unzip -ouq testAutoExeExpansion.zip)=0A=
    assert_equal(0, $?.exitstatus, "unzip failed!")=0A=
  end=0A=
=0A=
  # Check that zip/unzip with exe file in archive first=0A=
  # This causes problems.=0A=
  def test_unzipExeFirst=0A=
    %x(zip testAutoExeExpansion.zip testAutoExeExpansion/test.exe)=0A=
    assert_equal(0, $?.exitstatus, "zip1 failed!")=0A=
    %x(zip -r testAutoExeExpansion.zip testAutoExeExpansion/test/)=0A=
    assert_equal(0, $?.exitstatus, "zip2 failed!")=0A=
    %x(rm -r testAutoExeExpansion/)=0A=
=0A=
    %x(unzip -ouq testAutoExeExpansion.zip)=0A=
    assert_equal(0, $?.exitstatus, "unzip failed!")=0A=
  end=0A=
=0A=
  # Check that zip/unzip with exe file in archive first, exclude problemati=
c directory workaround=0A=
  # This causes problems.=0A=
  def test_unzipExeFirstExclude=0A=
    %x(zip testAutoExeExpansion.zip testAutoExeExpansion/test.exe)=0A=
    assert_equal(0, $?.exitstatus, "zip1 failed!")=0A=
    %x(zip -r testAutoExeExpansion.zip testAutoExeExpansion/test/)=0A=
    assert_equal(0, $?.exitstatus, "zip2 failed!")=0A=
    %x(rm -r testAutoExeExpansion/)=0A=
=0A=
    %x(unzip -ouq testAutoExeExpansion.zip -x testAutoExeExpansion/test/ )=
=0A=
    assert_equal(0, $?.exitstatus, "unzip failed!")=0A=
  end=0A=
=0A=
  # Check that find can locate and remove directory with co-located exe file=
=0A=
  # This causes problems.=0A=
  def test_findrmr=0A=
    %x(find testAutoExeExpansion -path testAutoExeExpansion/test -type d -e=
xec rm -r {}/ \\;)=0A=
    assert_equal(0, $?.exitstatus, "find failed!")=0A=
  end=0A=
=0A=
  # Check that find can locate and remove directory with co-located exe file=
=0A=
  # This causes problems.=0A=
  def test_findrmdir=0A=
    %x(find testAutoExeExpansion -path testAutoExeExpansion/test -type d -e=
xec rmdir {}/ \\;)=0A=
    assert_equal(0, $?.exitstatus, "find failed!")=0A=
  end=0A=
=0A=
end=0A=


------=_NextPart_000_000A_01D20535.D5D24AE0
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
------=_NextPart_000_000A_01D20535.D5D24AE0--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019