Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!munnari.OZ.AU!news.ecn.uoknor.edu!solace!nntp.se.dataphone.net!nntp.uio.no!news.apfel.de!fu-berlin.de!thimm.dialup.fu-berlin.DE!not-for-mail From: thimm@physik.fu-berlin.de (Axel Thimm) Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: sh bug? Date: Thu, 13 Mar 1997 11:18:49 GMT Organization: FU Berlin, Fachbereich Physik, Institut fuer Theoretische Physik Lines: 89 Message-ID: <3327db59.1518864@news.fu-berlin.de> References: <332369be.3271553@news.fu-berlin.de> <5g7ltp$ps@uriah.heep.sax.de> Reply-To: thimm@physik.fu-berlin.de NNTP-Posting-Host: thimm.dialup.fu-berlin.de (160.45.217.207) X-Access: 16 17 19 X-Newsreader: Forte Free Agent 1.1/32.230 Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:37060 j@uriah.heep.sax.de (J Wunsch) wrote: >thimm@physik.fu-berlin.de (Axel Thimm) wrote: >> Installing tetex on 2.1.0 a bug in sh showed up. >> It affects redirection like >&1 and makes Thomas Esser's life harder to >> keep tetex portable. bash is working fine. >> Is this a known bug, has it been fixed in 2.1.7? (This bug shows up when >> calling MakeTeXPK in recent tetex releases) > >Please don't assume everybody is happy to suck several megabytes of >TeTeX just to verify a shell bug. Better isolate the bug in a minimum >script. What's wrong about the redirections? This was not my intention, I hoped that this might be something known. I better give some (lengthy) details (further below). >I hope it's not the old buggy script that had an unterminated string ^^^ no, in fact it is new due to a request of the xdvi author >Btw., bash is by far nothing you could count as a reference shell. If >at all, use a genuine ksh, then at least you've got what the Posix >consortium deemed the only shell. The comparison was only because bash is working correctly with the redirections. I am not a shell expert. In order to gove some info here are some parts of a dicussion in the tetex list about it: (I think in a nutshell, that sh cannot cope with redirection to >&1.) The original problem. >> /usr/local/teTeX/bin/i386-freebsd2.1.0/MakeTeXPK: 1: Syntax error: Bad fd >> number > >I guess that this error comes from: > cat $TEMPDIR/mtout.$$ >&$REDIRECT >where $REDIRECT=1 (usually). I.e. the command should output the name of >the generated file to stdout. This did work with all shells I have >seen so far. A comment from a NetBSD/i386 1.2 PC user with a workaround, that doesn't work for FreeBSD (2.1.0) >None of these works in my environment: > > sh -c 'a=1; echo hi >&$a' > sh -c 'a=1; eval echo hi \>\&$a' > sh -c 'echo hi >&1' > >But this is ok: > > sh -c 'a=2; echo hi >&$a' > bash -c 'a=1; echo hi >&$a' > >A not verry nice workaround: > > sh -c 'a=1; case $a in 1) echo hi ;; *) echo hi >&$a; esac' > Some attempts to overcome the problem. >> Hm... Seems like the redirection causes trouble, even though being hidden by >> the case command. Please try the following: >> #!/bin/sh >> case 1 in 1) ;; *) echo >&1; esac >> >> It should not output anything. > >This is what I get: >puariko(28):~> cat tetex.tst >#!/bin/sh >uname -a >echo x1 >case 1 in 1) ;; *) echo >&1; esac >echo x2 >case 1 in 1) ;; *) echo This >&1; esac >echo x3 >puariko(29):~> sh ./tetex.tst >FreeBSD puariko 2.1.0-RELEASE FreeBSD 2.1.0-RELEASE #0: Fri Oct 11 16:37:48 >MET DST 1996 root@puariko:/usr/src/sys/compile/KERNEL_CONFIG i386 >x1 >x2 >x3 >puariko(30):~> Regards, Axel. -- Axel Thimm thimm@physik.fu-berlin.de thimm@ifh.de