This how I think fixed patch should look like.
It's only quick hack but for now it's best thing I have.
diff -rup ~dash-0.5.6.1/src/error.h dash-0.5.6.1/src/error.h
--- ~dash-0.5.6.1/src/error.h 2010-06-24 23:53:42.000000000 +0200
+++ dash-0.5.6.1/src/error.h 2010-06-24 23:50:58.000000000 +0200
@@ -69,6 +69,7 @@ extern int exception;
#define EXSHELLPROC 2 /* execute a shell procedure */
#define EXEXEC 3 /* command execution failed */
#define EXEXIT 4 /* exit the shell */
+#define EXIFILE 5 /* inputfile cannot be opened or is a directory */
/*
diff -rup ~dash-0.5.6.1/src/input.c dash-0.5.6.1/src/input.c
--- ~dash-0.5.6.1/src/input.c 2010-06-24 23:53:42.000000000 +0200
+++ dash-0.5.6.1/src/input.c 2010-06-25 00:45:19.000000000 +0200
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
/*
* This file implements the input routines used by the parser.
@@ -54,6 +55,7 @@
#include "parser.h"
#include "main.h"
#include "var.h"
+#include "eval.h"
#ifndef SMALL
#include "myhistedit.h"
#endif
@@ -400,15 +402,28 @@ popstring(void)
*/
int
+isdir(const char *name)
+{
+ struct stat64 st;
+ if (stat64(name, &st) < 0)
+ return -1;
+ if (S_ISDIR(st.st_mode)) {
+ return -1;
+ }
+ return 0;
+}
+
+int
setinputfile(const char *fname, int flags)
{
int fd;
INTOFF;
- if ((fd = open(fname, O_RDONLY)) < 0) {
+ if ((isdir(fname) < 0) || ((fd = open(fname, O_RDONLY)) < 0)) {
if (flags & INPUT_NOFILE_OK)
goto out;
- sh_error("Can't open %s", fname);
+ exitstatus = 127;
+ exerror(EXIFILE, "Can't open %s", fname);
}
if (fd < 10)
fd = savefd(fd, fd);
--
X was an interactive protocol:
alpha blending a full-screen image looked like slugs racing down the monitor.
http://www.keithp.com/~keithp/talks/usenix2000/render.html