Re: for; do; done regression ?

2011-01-10 Thread Jan Schampera

Marc Herbert wrote:


seq is not exactly Linux-only but GNU-only.

GNU-specific versus bash-specific, which is worse? I'd say it
depends... on which mailing-list you post :-)


I'd say a script interpreted by the GNU shell must not rely blindly on 
GNU tools being installed or on running on a GNU OS. It can, however, 
rely on Bash features, of course.


--
Be conservative in what you do, be liberal in what you accept from others.
- jbp, master of the net, in RFC793




Re: 'help set' missing '--'

2011-01-10 Thread Jan Schampera

Dennis Williamson wrote:


I think this distinction from the man page is what's missing in the help:

> [...]

Exactly. Thanks for pointing it out, I thought it was clear :)

--
Be conservative in what you do, be liberal in what you accept from others.
- jbp, master of the net, in RFC793




Re: 'help set' missing '--'

2011-01-10 Thread Jan Schampera

Greg Wooledge wrote:


Or:

  set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]



More:

set [-abefhkmnptuvxBCHP] [-o option-name] [-] [--] [arg ...]

Plus: Describe '--' the same way '-' is described (with an extra part in 
the full help message below the synopsis).


--
Be conservative in what you do, be liberal in what you accept from others.
- jbp, master of the net, in RFC793




Re: for; do; done regression ?

2011-01-10 Thread Roman Rakus

On 01/10/2011 05:24 PM, Marc Herbert wrote:

Le 10/01/2011 13:38, Greg Wooledge a écrit :

Don't use seq, ever, because it's Linux-only
and is a stupid way to count when bash has builtin integer arithmetic.")

seq is not exactly Linux-only but GNU-only.

GNU-specific versus bash-specific, which is worse? I'd say it
depends... on which mailing-list you post :-)





I will say the same on both lists - why to execute another process if 
you can do the same in the current one? No gain.


RR



Re: for; do; done regression ?

2011-01-10 Thread Marc Herbert
Le 10/01/2011 13:38, Greg Wooledge a écrit :
> Don't use seq, ever, because it's Linux-only
> and is a stupid way to count when bash has builtin integer arithmetic.")

seq is not exactly Linux-only but GNU-only.

GNU-specific versus bash-specific, which is worse? I'd say it
depends... on which mailing-list you post :-)







Re: 'help set' missing '--'

2011-01-10 Thread Greg Wooledge
> >>SYNOPSIS
> >> set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]

On Mon, Jan 10, 2011 at 09:16:02AM -0500, Chris F.A. Johnson wrote:
> On Mon, 10 Jan 2011, Christopher Roy Bratusek wrote:
> >Hmm, one could read it as "--" "--a" "--b" and so on, maybe it could be
> >improved.
> 
>Agreed. Perhaps:
> 
>   set [-[-abefhkmnptuvxBCHP]] [-o option-name] [arg ...]

Or:

  set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]



Re: 'help set' missing '--'

2011-01-10 Thread Chris F.A. Johnson

On Mon, 10 Jan 2011, Christopher Roy Bratusek wrote:


On Monday 10 January 2011 09:06:42 Chris F.A. Johnson wrote:

On Mon, 10 Jan 2011, Jan Schampera wrote:

the help output for the set builtin command misses '--'.


It's there:

SYNOPSIS
 set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]


Hmm, one could read it as "--" "--a" "--b" and so on, maybe it could be
improved.


   Agreed. Perhaps:

  set [-[-abefhkmnptuvxBCHP]] [-o option-name] [arg ...]

--
   Chris F.A. Johnson, 
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)



Re: for; do; done regression ?

2011-01-10 Thread Greg Wooledge
On Fri, Jan 07, 2011 at 04:17:17AM +0300, Alexander Tiurin wrote:
> ~$ time for i in `seq 0 1`  ; do echo /o/23/4 | cut -d'/' -f2 ; done
> > /dev/null 

Others have already begun investigating the internal causes of the
slowdown.  But if you actually want this particular piece of code to
run more quickly, you can optimize it quite a bit:

x=/o/23/4
for ((i=0; i<=1; i++)); do tmp=${x#*/}; echo "${tmp%%/*}"; done

There's no need for all those forks you were doing.

(And then you're going to say "But this was just an example, and my real
code is more complex."  And you still won't show the real code.  And
we'll get in a big fight.  And everyone will be sad.  So all I can really
do for you is give general advice, like "Don't use echo|cut when you can
use parameter expansion.  Don't use seq, ever, because it's Linux-only
and is a stupid way to count when bash has builtin integer arithmetic.")

P.S.,

imadev:~$ bash-4.1.9
imadev:~$ x=/o/23/4
imadev:~$ time for ((i=0; i<=1; i++)); do tmp=${x#*/}; echo "${tmp%%/*}"; 
done >/dev/null

real0m2.080s
user0m2.020s
sys 0m0.040s
imadev:~$ time for ((i=0; i<=1; i++)); do tmp=${x#*/}; echo "${tmp%%/*}"; 
done >/dev/null

real0m2.082s
user0m2.020s
sys 0m0.050s
imadev:~$ time for ((i=0; i<=1; i++)); do tmp=${x#*/}; echo "${tmp%%/*}"; 
done >/dev/null

real0m2.118s
user0m2.050s
sys 0m0.050s



Re: 'help set' missing '--'

2011-01-10 Thread Dennis Williamson
On Mon, Jan 10, 2011 at 2:06 AM, Chris F.A. Johnson wrote:

> On Mon, 10 Jan 2011, Jan Schampera wrote:
>
>  the help output for the set builtin command misses '--'.
>>
>
>   It's there:
>
> SYNOPSIS
>set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
>
> --
>   Chris F.A. Johnson, 
>   Author:
>   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
>   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
>
> I think this distinction from the man page is what's missing in the help:

  --  If  no arguments follow this option, then the
positional
  parameters are unset.  Otherwise, the positional
parame‐
  ters  are  set  to  the args, even if some of them
begin
  with a -.
  -   Signal the end of options, cause all remaining  args
 to
  be assigned to the positional parameters.  The -x and
-v
  options are turned off.  If there are no args, the
posi‐
  tional parameters remain unchanged.


Re: 'help set' missing '--'

2011-01-10 Thread Chris F.A. Johnson

On Mon, 10 Jan 2011, Jan Schampera wrote:


the help output for the set builtin command misses '--'.


   It's there:

SYNOPSIS
set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]

--
   Chris F.A. Johnson, 
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)