This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Hello and cygwin quesiton


Dear Igor,
Nice to hear from you, and thanks for the clarification!

I understand your explanation of the difference between
gvim and vim.  But there is still a mystery.

In my previous installation of cygwin, no such problems
arise.  The difference is that my previous system was Windows 2000
and my current one is Windows XP.  Can you explain this?

Thanks,
--Chee

Igor Pechtchanski wrote:

On Tue, 30 Sep 2003, Yap on ExactGeom wrote:



Dear Igor,

How are you?  I noticed that you are an active developer of cygwin.
I really liked this platform and our Core Library is developed
on this mainly.   I have a question:

In my recent (June) installation of cygwin, there was an annoying
bug -- many of the files that I create are automatically given
the execute permission.  [Since my "ls" will automatically show
me which files are executable, this is VERY annoying.]
But this behavior is not universal.  If I have a non-executable
file, and I exit it using gvim, the file will become executable.
But using vim, it remains non-executable.  But I don't think
the program is with a bad installation of gvim, because this
phenomenon shows up in other places.

Heard of this bug before?
Thanks, Chee



Hi, Chee,


Great to hear from you.

I'm redirecting this reply to the general Cygwin list, mostly to get this
into the archives (because I know others are having this same problem).
Also, this brings your question up before a large body of expertise --
perhaps someone else will find something I've missed.

This is not a bug, but rather an artifact of the default permissions files
get when written by Windows programs. Gvim is a pure Windows program, in
contrast with vim, which is a Cygwin one. Also, vim writes files
in-place, whereas gvim creates a new copy -- hence the change in
permissions. Unfortunately, there isn't anything you can easily do to fix
this. I have a script (attached) that I run periodically on my system to
fix the executable permissions. It's not foolproof, but it's better than
nothing (and it should err on the conservative side).
Igor


------------------------------------------------------------------------

#!/bin/sh
#
# A script to fix up executable permissions.
#
# Copyright (c) 2002, 2003, Igor Pechtchanski
#
# Written by Igor Pechtchanski <pechtcha@cs.nyu.edu>
#
# This program is distributed under the terms of the GNU General Public
# License.  For more information see <http://www.gnu.org/licenses/>.
#

PROGNAME="`basename "$0"`"
USAGE="Usage: $PROGNAME [-v|--verbose] [-n|--dry-run] [-b|--batch] [dirs]"
DASH_PRINT=
ECHO=
TEE=cat
BATCH=
dup2() {
#  xargs -r -0 -n 1 perl -e 'exit unless ($a=shift);print STDERR "$a\n";print "$a\0"'
#  xargs -r -0 -n 100 perl -e 'foreach(@ARGV){print STDERR "$_\n";print "$_\0"}'
 perl -e '$/="\0";while(<>){chomp();print STDERR "$_\n";print "$_\0"}'
}
while [ -n "$1" ]; do
 case "$1" in
   -h|--help) echo "$USAGE" >&2 ; exit 0 ;;
   -v|--verbose) DASH_PRINT="-print" ; TEE=dup2 ;;
   -n|--dry-run) ECHO="echo" ;;
   -b|--batch) BATCH="true" ;;
   --) shift ; break ;;
   -*) echo "Invalid flag: $1" >&2 ; echo "$USAGE" >&2 ; exit 2 ;;
   *) break ;;
 esac
 shift
done

DIRS="${@:-.}"

#EXEEXT="sh exe bat com dll"
EXEEXT="exe bat com dll"
EXTFILTER="$(echo "$EXEEXT" | perl -pe 's/(\w+)/-name \\*.$1 -o/g')"

#DBGPRG='-exec echo CAUGHT ".(++$i)." {} \\;'
EXEPAT='^#! */^: *Use */eval.*exec'
#PATPRG='-exec perl -ne \"BEGIN{\\\$s=1};\\\$.=1&&/$p/&&exit(\\\$s=0);exit(\\\$s);END{exit(\\\$s)}\" {} \\;';
PATPRG='-exec awk \"BEGIN{S=1}NR=1&&/$p/{S=0;exit(0)}{exit(S)}END{exit(S)}\" {} \\;';
PATFILTER="$(echo "$EXEPAT" | perl -pe 's/\n$//;@p=split(//);foreach $p(@p){$p=~s@(['"'"'"/])@\\\\$1@g;$p="'"$PATPRG $DBGPRG"' -o";};$_=join(" ",@p)')"

eval "set -- $EXTFILTER $PATFILTER"

for DIR in $DIRS; do
 if [ -d "$DIR" -o -h "$DIR" ]; then
   FILTER="-type f"
 elif [ -f "$DIR" ]; then
   FILTER="-maxdepth 1"
 fi
 if [ -z "$BATCH" ]; then
   find "$DIR" $FILTER -perm -0100 \( "$@" \( $DASH_PRINT -exec $ECHO chmod a-x {} \; \) \)
 else
   find "$DIR" $FILTER -perm -0100 \( "$@" -print0 \) | $TEE | xargs -r -0 -n 1000 $ECHO chmod a-x --
 fi
done





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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]