This is the mail archive of the
cygwin
mailing list for the Cygwin project.
[patch 1/8] Add EXECIGNORE special variable
- From: dan dot colascione at gmail dot com
- To: cygwin at cygwin dot com
- Date: Tue, 02 Nov 2010 13:48:56 -0700
- Subject: [patch 1/8] Add EXECIGNORE special variable
- References: <20101102204855.153395100@gmail.com>
Index: bash-3.2/findcmd.c
===================================================================
--- bash-3.2.orig/findcmd.c
+++ bash-3.2/findcmd.c
@@ -44,6 +44,8 @@
#include "hashcmd.h"
#include "findcmd.h" /* matching prototypes and declarations */
+#include <glob/strmatch.h>
+
extern int posixly_correct;
/* Static functions defined and used in this file. */
@@ -72,6 +74,40 @@ int check_hashed_filenames;
containing the file of interest. */
int dot_found_in_search = 0;
+static struct ignorevar execignore =
+{
+ "EXECIGNORE",
+ (struct ign *)0,
+ 0,
+ (char *)0,
+ (sh_iv_item_func_t *)0,
+};
+
+void
+setup_exec_ignore (varname)
+ char *varname;
+{
+ setup_ignore_patterns (&execignore);
+}
+
+/* Return whether we should never consider file executable
+ * even if the system tells us it is. */
+static int
+is_on_exec_blacklist (name)
+ char *name;
+{
+ struct ign *p;
+ int flags = FNM_EXTMATCH | FNM_CASEFOLD;
+
+ for (p = execignore.ignores; p && p->val; p++)
+ {
+ if (strmatch (p->val, (char *)name, flags) != FNM_NOMATCH)
+ return (1);
+ }
+
+ return (0);
+}
+
/* Return some flags based on information about this file.
The EXISTS bit is non-zero if the file is found.
The EXECABLE bit is non-zero the file is executble.
@@ -98,7 +134,7 @@ file_status (name)
/* We have to use access(2) to determine access because AFS does not
support Unix file system semantics. This may produce wrong
answers for non-AFS files when ruid != euid. I hate AFS. */
- if (access (name, X_OK) == 0)
+ if (is_on_exec_blacklist (name) == 0 && access (name, X_OK) == 0)
r |= FS_EXECABLE;
if (access (name, R_OK) == 0)
r |= FS_READABLE;
@@ -147,6 +183,9 @@ file_status (name)
r |= FS_READABLE;
}
+ if (is_on_exec_blacklist (name))
+ r &= ~FS_EXECABLE;
+
return r;
#endif /* !AFS */
}
Index: bash-3.2/findcmd.h
===================================================================
--- bash-3.2.orig/findcmd.h
+++ bash-3.2/findcmd.h
@@ -31,5 +31,6 @@ extern char *find_user_command __P((cons
extern char *find_path_file __P((const char *));
extern char *search_for_command __P((const char *));
extern char *user_command_matches __P((const char *, int, int));
+extern void setup_exec_ignore __P((char *));
#endif /* _FINDCMD_H_ */
Index: bash-3.2/pathexp.h
===================================================================
--- bash-3.2.orig/pathexp.h
+++ bash-3.2/pathexp.h
@@ -68,7 +68,7 @@ extern char *quote_globbing_chars __P((c
extern char **shell_glob_filename __P((const char *));
/* Filename completion ignore. Used to implement the "fignore" facility of
- tcsh and GLOBIGNORE (like ksh-93 FIGNORE).
+ tcsh and GLOBIGNORE (like ksh-93 FIGNORE) and EXECIGNORE.
It is passed a NULL-terminated array of (char *)'s that must be
free()'d if they are deleted. The first element (names[0]) is the
@@ -84,7 +84,7 @@ struct ign {
typedef int sh_iv_item_func_t __P((struct ign *));
struct ignorevar {
- char *varname; /* FIGNORE or GLOBIGNORE */
+ char *varname; /* FIGNORE or GLOBIGNORE or EXECIGNORE */
struct ign *ignores; /* Store the ignore strings here */
int num_ignores; /* How many are there? */
char *last_ignoreval; /* Last value of variable - cached for speed */
Index: bash-3.2/variables.c
===================================================================
--- bash-3.2.orig/variables.c
+++ bash-3.2/variables.c
@@ -3749,6 +3749,8 @@ static struct name_and_function special_
{ "GLOBIGNORE", sv_globignore },
+ { "EXECIGNORE", sv_execignore },
+
#if defined (HISTORY)
{ "HISTCONTROL", sv_history_control },
{ "HISTFILESIZE", sv_histsize },
@@ -3914,6 +3916,14 @@ sv_globignore (name)
setup_glob_ignore (name);
}
+/* What to do when EXECIGNORE changes. */
+void
+sv_execignore (name)
+ char *name;
+{
+ setup_exec_ignore (name);
+}
+
#if defined (READLINE)
void
sv_comp_wordbreaks (name)
Index: bash-3.2/variables.h
===================================================================
--- bash-3.2.orig/variables.h
+++ bash-3.2/variables.h
@@ -331,6 +331,7 @@ extern void sv_ifs __P((char *));
extern void sv_path __P((char *));
extern void sv_mail __P((char *));
extern void sv_globignore __P((char *));
+extern void sv_execignore __P((char *));
extern void sv_ignoreeof __P((char *));
extern void sv_strict_posix __P((char *));
extern void sv_optind __P((char *));
--
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