tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Weirdness in /bin/sh of 8.0



    Date:        Sun, 12 Aug 2018 20:23:05 +0200
    From:        Rhialto <rhialto%falu.nl@localhost>
    Message-ID:  <20180812182305.GC5616%falu.nl@localhost>

  | I tried commenting out some stuff related to the -v option, and if I do
  | this, then it works:

  | Maybe the redirection isn't reset in some cases?

That is exactly it.    The problem is related to the (somewhat botched) fix
for PR bin/48875 (with which Edgar may be familiar...) which has been
known to be not correct for ages (the PR was last touched June 2016)
but which, until now, never caused any observable side effects.

This patch ...

Index: eval.c
===================================================================
RCS file: /cvsroot/src/bin/sh/eval.c,v
retrieving revision 1.156
diff -u -r1.156 eval.c
--- eval.c	25 Jul 2018 14:42:50 -0000	1.156
+++ eval.c	13 Aug 2018 00:01:29 -0000
@@ -1059,7 +1059,7 @@
 	case CMDFUNCTION:
 		VXTRACE(DBG_EVAL, ("Shell function%s:  ",vforked?" VF":""),
 		    trargs(argv));
-		redirect(cmd->ncmd.redirect, flags & EV_MORE ? REDIR_PUSH : 0);
+		redirect(cmd->ncmd.redirect, REDIR_PUSH);
 		saveparam = shellparam;
 		shellparam.malloc = 0;
 		shellparam.reset = 1;

will fix that particular problem (though it is not tested properly yet, I
do not know if just this would have other side effects) ... EV_MORE
was the PR 48875 fix - it is attempting to work out whether redirected
fds need to be kept open (as an open fd which was unused was the
cause of the issue in the PR)

This is certainly not the right way to fix things, but as a quick fix to allow
pkg_chk -av to work, it seems adequate (at least as much as I can test
that, since I don't use pkg_chk and don't have a pkgchk.conf file with
anything meaningful in it).

I will push doing a proper fix for 48875 up my priority list, rather than
just letting it languish as an intellectual curiosity that ought be handled
sometime...

kre

ps: that patch is for current, but I expect it should apply to -8 wthout any
issues.

pps: while looking at this, I see a whole bunch of problems in the pkg_chk
script that ought to be fixed, but none of them are related to this particular
issue.



Home | Main Index | Thread Index | Old Index