/* Is there any system that doesn't have access()? */
#define USE_MCH_ACCESS
+#if defined(sun) && defined(S_ISCHR)
+# define OPEN_CHR_FILES
+static int is_dev_fd_file(char_u *fname);
+#endif
#ifdef FEAT_MBYTE
static char_u *next_fenc __ARGS((char_u **pp));
# ifdef FEAT_EVAL
# endif
# ifdef S_ISSOCK
&& !S_ISSOCK(perm) /* ... or socket */
+# endif
+# ifdef OPEN_CHR_FILES
+ && !(S_ISCHR(perm) && is_dev_fd_file(fname))
+ /* ... or a character special file named /dev/fd/<n> */
# endif
)
{
}
# endif
# endif
+# ifdef OPEN_CHR_FILES
+ if (S_ISCHR(perm)) /* or character special */
+ {
+ STRCAT(IObuff, _("[character special]"));
+ c = TRUE;
+ }
+# endif
#endif
if (curbuf->b_p_ro)
{
return OK;
}
+#ifdef OPEN_CHR_FILES
+/*
+ * Returns TRUE if the file name argument is of the form "/dev/fd/\d\+",
+ * which is the name of files used for process substitution output by
+ * some shells on some operating systems, e.g., bash on SunOS.
+ * Do not accept "/dev/fd/[012]", opening these may hang Vim.
+ */
+ static int
+is_dev_fd_file(fname)
+ char_u *fname;
+{
+ return (STRNCMP(fname, "/dev/fd/", 8) == 0
+ && VIM_ISDIGIT(fname[8])
+ && *skipdigits(fname + 9) == NUL
+ && (fname[9] != NUL
+ || (fname[8] != '0' && fname[8] != '1' && fname[8] != '2')));
+}
+#endif
+
#ifdef FEAT_MBYTE
/*
#if !defined(S_ISFIFO) && defined(S_IFIFO)
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
+#if !defined(S_ISCHR) && defined(S_IFCHR)
+# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#endif
/* Note: Some systems need both string.h and strings.h (Savage). However,
* some systems can't handle both, only use string.h in that case. */