1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

better v=$(<file) fix (re: fe6d0903)

If we're adding a check for flag==3 to limit the fix to v=$(<file),
we might as well use the existing check upon returning the FD.
This commit is contained in:
Martijn Dekker 2020-09-22 14:39:28 +02:00
parent e149cf4fd8
commit 7444fc7c24

View file

@ -1266,8 +1266,6 @@ int sh_redirect(Shell_t *shp,struct ionod *iop, int flag)
if(flag==SH_SHOWME)
goto traceit;
fd=sh_chkopen(fname);
if(flag==3) /* make sure that $(<file) works... */
fd=sh_iomovefd(fd); /* ...with stdin/stdout/stderr closed */
}
else if(sh_isoption(SH_RESTRICTED))
errormsg(SH_DICT,ERROR_exit(1),e_restricted,fname);
@ -1447,7 +1445,7 @@ int sh_redirect(Shell_t *shp,struct ionod *iop, int flag)
sh_close(fn);
}
if(flag==3)
return(fd);
return(sh_iomovefd(fd)); /* ensure FD > 2 to make $(<file) work with std{in,out,err} closed */
if(fd>=0)
{
if(np)