On Tue, 23 May 2023 22:22:04 -0000, Klemens Nanni wrote:
> I'm pointing this out because the error message we'd get provides less
> information with your diff:
>
> $ echo $(cat /nope) 2>/dev/null
> cat: /nope: No such file or directory
> vs.
> echo $(< /nope) 2>/dev/null
> ksh: /nope: cannot open $(<) input
>
> But given the constraint environment, I'm fine with turning those four
> $(cat ...) instances into $(< ...) like the exising seven onces with
> the intial example being the only outlier.
Here's the error output from bash, zsh and ksh93:
$bash echo $(< /nope)
bash: /nope: No such file or directory
$zsh echo $(< /nope)
zsh: no such file or directory: /nope
$ksh93 echo $(< /nope)
ksh93: /nope: cannot open [No such file or directory]
Maybe we should just adjust ksh to display the more useful message?
With diff:
$ echo $(< /nope)
ksh: /nope: No such file or directory
- todd
diff -u -p -u -r1.66 eval.c
--- bin/ksh/eval.c 13 Sep 2020 15:39:09 -0000 1.66
+++ bin/ksh/eval.c 24 May 2023 14:03:41 -0000
@@ -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];