Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Ralph Graulich
> Folks, I think the aim of all shell scripts in groff is to be POSIX > `sh' compatible. In case there are bashisms, they should be removed > and/or circumvented. I second that! "sh" is the lowest common denominator on nearly all UNIX operating systems in existence. Therefore one should strive f

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Werner LEMBERG
>> #!/bin/sh >> # This script is written for the bash shell. See bash(1). >> >> Or is that just too obvious? > > Wouldn't #!/bin/bash be more obvious and less error-prone? Folks, I think the aim of all shell scripts in groff is to be POSIX `sh' compatible. In case there are bashisms, they sh

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Peter Schaffter
On Fri, Jan 03, 2014, Roger Leigh wrote: > > #!/bin/sh > > # This script is written for the bash shell. See bash(1). > > > > Or is that just too obvious? > > It's incorrect. If you're writing a script for the bash shell, then > all you need to do is use > > #!/bin/bash > > and then you'll be

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Ralph Corderoy
Hi Doug, > I must be missing something in the discussion about random > numbers. Why does groff need them? In the offered example > tmp="$d/eqn2graph$groff_rand" > the "random number" serves only to make a (supposedly) unique > name. But of course, if the number is truly random, it is not > gu

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Daode
Doug McIlroy wrote: |I must be missing something in the discussion about random |numbers. Why does groff need them? In the offered example |tmp="$d/eqn2graph$groff_rand" |the "random number" serves only to make a (supposedly) unique |name. But of course, if the number is truly random, it

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Doug McIlroy
I must be missing something in the discussion about random numbers. Why does groff need them? In the offered example tmp="$d/eqn2graph$groff_rand" the "random number" serves only to make a (supposedly) unique name. But of course, if the number is truly random, it is not guaranteed to be unique.

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Mike Bianchi
On Thu, Jan 02, 2014 at 09:12:38PM -0500, Peter Schaffter wrote: > On Thu, Jan 02, 2014, Mike Bianchi wrote: > > How is someone attempting to understand a #!/bin/sh script to know what > > the > > writer intended if there is no documented way to interpret the syntax? > > #!/bin/sh > # This scri

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Roger Leigh
On Thu, Jan 02, 2014 at 09:12:38PM -0500, Peter Schaffter wrote: > On Thu, Jan 02, 2014, Mike Bianchi wrote: > > How is someone attempting to understand a #!/bin/sh script to know what > > the > > writer intended if there is no documented way to interpret the syntax? > > #!/bin/sh > # This scri

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Ralph Corderoy
Hi Mike, > Please define what a non-standard extension shell is. Something that isn't in POSIX's sh. > My point is that #!/bin/sh is the name of a shell command that is > not documented. In fact it does not exist anymore. There are many shells that aim to provide all of POSIX's sh's behaviou

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-03 Thread Ralph Corderoy
Hi, Tethys wrote: > Since it's not guaranteed to be present, why not just ignore $RANDOM > and use our own randomly generated integer instead? Something like: > > groff_rand=$(dd if=/dev/urandom bs=8 count=1 2>/dev/null | sum | sed > 's/^0*//;s/ .*//') > tmp="$d/eqn2graph$groff_rand

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Peter Schaffter
On Thu, Jan 02, 2014, Mike Bianchi wrote: > How is someone attempting to understand a #!/bin/sh script to know what the > writer intended if there is no documented way to interpret the syntax? #!/bin/sh # This script is written for the bash shell. See bash(1). Or is that just too obvious? --

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Mike Bianchi
On Thu, Jan 02, 2014 at 04:07:20PM +, Roger Leigh wrote: > On Thu, Jan 02, 2014 at 05:00:04PM +0100, Ingo Schwarze wrote: > > Hi Mike, > > > > Mike Bianchi wrote: > > > > > There is no man page for sh(1) . > > > There is no executable for /bin/sh . On Debian ... > > > > Sorry if that answ

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Ingo Schwarze
Hi, Tethys wrote on Fri, Jan 03, 2014 at 12:06:31AM +: > Colin Watson writes: >>Perhaps just: >> >> tmp=$d/eqn2graph$${$RANDOM:+-$RANDOM} >> >>then? That, or just tmp=$d/eqn2graph$$-`date +%Y%m%d%H%M%S` A collision is not dangerous in terms of security, and we are only talking about a f

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Tethys
Colin Watson writes: >Perhaps just: > > tmp=$d/eqn2graph$${$RANDOM:+-$RANDOM} > >then? Since it's not guaranteed to be present, why not just ignore $RANDOM and use our own randomly generated integer instead? Something like: groff_rand=$(dd if=/dev/urandom bs=8 count=1 2>/dev/null | sum

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Ingo Schwarze
Hi, Roger Leigh wrote on Thu, Jan 02, 2014 at 04:07:20PM +: > It isn't broken. It's just a minimal POSIX shell. It will work > fine with any script, providing you aren't using any non-standard > bash, ksh or zsh extensions. There might possibly be some new > POSIX shell standard features w

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Roger Leigh
On Thu, Jan 02, 2014 at 05:00:04PM +0100, Ingo Schwarze wrote: > Hi Mike, > > Mike Bianchi wrote: > > > There is no man page for sh(1) . > > There is no executable for /bin/sh . On Debian ... > > Sorry if that answer seems blunt, but it is not groff's > problem if the shell is broken in Debia

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Ingo Schwarze
Hi Mike, Mike Bianchi wrote: > There is no man page for sh(1) . > There is no executable for /bin/sh . On Debian ... Sorry if that answer seems blunt, but it is not groff's problem if the shell is broken in Debian. > For those reasons, I think #!/bin/sh should be outlawed! Hilarious. :-D

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Daode
Ralph Corderoy wrote: |Hi Steffen, | |> I'd really rather do something like the below instead. |... |> -tmp=$d/eqn2graph$$-$RANDOM |> +tmp=$d/eqn2graph$$-${RANDOM:-${$}} | |That's assuming the environment doesn't contain a RANDOM from somewhere. ph! |:-) | |Cheers, Ralph.

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Daode
Colin Watson wrote: |I suppose it isn't a fatal incompatibility, since $RANDOM just expands |to the empty string on other shells and mkdir will probably fail; maybe |we could just leave it alone since the above is really no better than |that.[.] yes of course. It was just me seeing /bin/bash,

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Colin Watson
On Thu, Jan 02, 2014 at 03:03:48PM +0100, Steffen Nurpmeso wrote: > Colin Watson wrote: > |+2014-01-02 Colin Watson > |+ > |+ * contrib/eqn2graph/eqn2graph.sh: Use bash rather than sh; $RANDOM > |+ is a bashism. > |+ * contrib/grap2graph/grap2graph.sh: Likewise. > |+ * con

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Ralph Corderoy
Hi Steffen, > I'd really rather do something like the below instead. ... > -tmp=$d/eqn2graph$$-$RANDOM > +tmp=$d/eqn2graph$$-${RANDOM:-${$}} That's assuming the environment doesn't contain a RANDOM from somewhere. :-) Cheers, Ralph.

Re: [Groff] [PATCH] Use bash for several contrib scripts

2014-01-02 Thread Daode
Happy new year. Colin Watson wrote: |+2014-01-02 Colin Watson |+ |+ * contrib/eqn2graph/eqn2graph.sh: Use bash rather than sh; $RANDOM |+ is a bashism. |+ * contrib/grap2graph/grap2graph.sh: Likewise. |+ * contrib/pic2graph/pic2graph.sh: Likewise. I'd really rather do so