delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/04/07/18:03:37

From: noer AT cygnus DOT com (Geoffrey Noer)
Subject: Re: cygwinb19.1.dll sh.exe still won't run shell scripts from path + workaround
7 Apr 1998 18:03:37 -0700 :
Message-ID: <199804080049.RAA28358.cygnus.cygwin32.developers@skaro.cygnus.com>
References: <3511d0b3 DOT 7373047 AT smtp DOT netzone DOT com>
To: jeffdb AT netzone DOT com
Cc: cygwin32-developers AT cygnus DOT com

Hi,

I committed the following patch of yours.  Here's the ChangeLog entry
I added for it.  Please send me any corrections if it's inaccurate:

Tue Apr  7 17:18:05 1998  Geoffrey Noer  <noer AT cygnus DOT com>

        patch from Mikey (jeffdb AT netzone DOT com):
        * fhandler.cc (fhandler_disk_file::open): under Win95, set
        S_IXOTH|S_IXGRP|S_IXGRP if the first two bytes of a file contain
        a '#!'.
        (fhandler_disk_file::check_execable_p): consider shell scripts
        execable

Regards,

-- 
Geoffrey Noer
noer AT cygnus DOT com

Mikey wrote:
> 
> --- fhandler.cc	1998/03/19 07:38:31	1.1
> +++ fhandler.cc	1998/03/19 07:13:33
> @@ -1086,6 +1086,25 @@
>  
>    res = this->fhandler_base::open (real_path.get_win32 (), flags, mode);
>  
> +
> +  if ((get_os_type () != winNT) && (!real_path.exec_p))
> +    {
> +    DWORD done;
> +    char magic[2];
> +    /* FIXME should we use /etc/magic ? */
> +    magic[0] = magic[1] = magic[2] = '\0';
> +    ReadFile (get_handle (), magic, 3, &done, 0);
> +    if (magic[0] == ':' && magic[1] == '\n')
> +        real_path.exec_p = 1;
> +
> +    if (magic[0] == '#' && magic[1] == '!')
> +        real_path.exec_p = 1;
> +    if (flags & O_APPEND)
> +      SetFilePointer (get_handle(), 0, 0, FILE_END);
> +    else
> +      SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
> +    }
> +
>    symlink_p_ = real_path.symlink_p;
>    execable_p_ = real_path.exec_p;
>  
> @@ -1255,9 +1274,9 @@
>  
>    if (strcasecmp (".bat", ch) == 0
>        || strcasecmp (".exe", ch) == 0
> -      || strcasecmp (".com", ch) == 0)
> +      || strcasecmp (".com", ch) == 0
> +      || strcasecmp (".shc", ch) == 0) /* file associate sh -c == ShellScript */
>      return 1;
> -
>    return 0;
>  }

- Raw text -


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