Skip to content

Commit

Permalink
better v=$(<file) fix (re: fe6d090)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
McDutchie committed Sep 22, 2020
1 parent e149cf4 commit 7444fc7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/cmd/ksh93/sh/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7444fc7

Please sign in to comment.