delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/01/29/12:20:31

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Wed, 29 Jan 2003 12:18:00 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Harald Kierer <Harald DOT Kierer AT astrum DOT de>
cc: "'Kevin Layer'" <layer AT franz DOT com>, <cygwin AT cygwin DOT com>
Subject: RE: sh/rm bug -- rm doesn't remove a file when run from cmd
In-Reply-To: <8C6D4989662C304087C58904BAB721A54B7358@Hermes.astrum.de>
Message-ID: <Pine.GSO.4.44.0301291156020.24195-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

On Wed, 29 Jan 2003, Harald Kierer wrote:

> > Found the problem: I had a file named `rm':
> >
> > D:\acl62\src\cl\src>ls -l rm
> > -rw-r--r--    1 layer    None            0 Jan 28 15:47 rm
> > D:\acl62\src\cl\src>getfacl rm
> > # file: rm
> > # owner: layer
> > # group: None
> > user::rw-
> > group::r--
> > other:r--
> > mask:rwx
> >
> > D:\acl62\src\cl\src>
> >
> > Now, it seems odd that `sh' (but not `bash' nor `sh' on Solaris) would
> > try and execute this.
>
> My guess: When you start bash your pwd gets changed. Check your last line in
> /etc/profile. So your "faulty" 0-byte rm is not found.
> sh doesnt change the pwd, so it uses the 0-byte rm.
> Bye,
>  Harry

Nope, bash doesn't change pwd unless a --login flag is given (and if it
did, it wouldn't be able to find the file in the current directory to
remove, would it?).

Bash is apparently using Cygwin's permission bits to determine whether
something is executable, while sh uses some other mechanism (it could be
as simple as where the stat routine is called from -- can't say more
without looking at the source).  A simple test shows that (this behavior
presupposes that "." is in the front of the PATH, as it usually is on
Windows):
====================================================================
C:\cygwin\tmp\pathtest>ls -l
total 1
-rw-r--r--    1 igor     None            0 Jan 29 11:58 aaa
-rw-r--r--    1 igor     None           27 Jan 29 11:56 rm

C:\cygwin\tmp\pathtest>cat rm
echo Running '"'rm "$@"'"'

C:\cygwin\tmp\pathtest>getfacl rm
# file: rm
# owner: igor
# group: None
user::---
group::---
other::---
mask::rwx

C:\cygwin\tmp\pathtest>sh -c "type rm"
rm is ./rm

C:\cygwin\tmp\pathtest>sh -c "rm -i aaa"
Running "rm -i aaa"

C:\cygwin\tmp\pathtest>bash -c "type rm"
rm is /usr/bin/rm

C:\cygwin\tmp\pathtest>bash -c "rm -i aaa"
rm: remove `aaa'? n

====================================================================
Oh, and by the way, some more data points:
====================================================================
C:\cygwin\tmp\pathtest>ksh -c "type rm"
rm is a tracked alias for /usr/bin/rm

C:\cygwin\tmp\pathtest>ksh -c "rm -i aaa"
rm: remove `aaa'? n

C:\cygwin\tmp\pathtest>C:\cygwin\tmp\pathtest>which rm
/usr/bin/rm
====================================================================
so ksh and "which" apparently uses the same mechanism as bash...

FYI,
C:\cygwin\tmp\pathtest>cygcheck -c bash ash
Cygwin Package Information
Package             Version
ash                 20020731-1
bash                2.05b-8

C:\cygwin\tmp\pathtest>ksh -c "echo $KSH_VERSION"
@(#)PD KSH v5.2.14 99/07/13.2

	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
  -- /usr/games/fortune


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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