ksh: make $(< filename) error output include the errno string.
authormillert <millert@openbsd.org>
Wed, 24 May 2023 14:20:33 +0000 (14:20 +0000)
committermillert <millert@openbsd.org>
Wed, 24 May 2023 14:20:33 +0000 (14:20 +0000)
This is more consistent with how bash, zsh and ksh93 behave and
makes $(< filename) more of a drop-in replacment for $(cat filename).
OK kn@ florian@

bin/ksh/eval.c

index 2f22c2e..deca584 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: eval.c,v 1.66 2020/09/13 15:39:09 tb Exp $    */
+/*     $OpenBSD: eval.c,v 1.67 2023/05/24 14:20:33 millert Exp $       */
 
 /*
  * Expansion - quoting, separation, substitution, globbing
@@ -8,6 +8,7 @@
 
 #include <ctype.h>
 #include <dirent.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <pwd.h>
 #include <stdio.h>
@@ -909,7 +910,7 @@ comsub(Expand *xp, char *cp)
                        SHF_MAPHI|SHF_CLEXEC);
                if (shf == NULL)
                        warningf(!Flag(FTALKING),
-                           "%s: cannot open $(<) input", name);
+                           "%s: %s", name, strerror(errno));
                xp->split = 0;  /* no waitlast() */
        } else {
                int ofd1, pv[2];