Re: let's set the positional parameters with a simple 'read'

2012-01-04 Thread Greg Wooledge
On Wed, Jan 04, 2012 at 02:38:22PM +0800, jida...@jidanni.org wrote: > Hmmm, as S. CHAZELAS said seems zsh also gives one a chance to reset an > arbitrary positional parameter, e.g., the 42nd, whereas in bash one must > set them all at once: That is why named arrays are COMPLETELY superior and sho

Re: let's set the positional parameters with a simple 'read'

2012-01-03 Thread jidanni
Hmmm, as S. CHAZELAS said seems zsh also gives one a chance to reset an arbitrary positional parameter, e.g., the 42nd, whereas in bash one must set them all at once: $ set `seq 55` $ echo $42 42 $ echo $66 66 :-) Anyway isn't it rather old fashioned not to be able to somehow reset ${42} without ne

Re: let's set the positional parameters with a simple 'read'

2012-01-03 Thread Stephane CHAZELAS
2012-01-04, 01:46(+08), jida...@jidanni.org: >> "GW" == Greg Wooledge writes: >GW> Why not just use a named array? >GW> $ read -a myarray > But does that let me get a my favorite array, the positional parameters? FWIW, in zsh: ~$ read -A argv a b c ~$ echo $1 a ~$ read 1 x ~$ echo $1 x See

Re: let's set the positional parameters with a simple 'read'

2012-01-03 Thread Eric Blake
On 01/03/2012 10:46 AM, jida...@jidanni.org wrote: >> "GW" == Greg Wooledge writes: > GW> Why not just use a named array? > GW> $ read -a myarray > But does that let me get a my favorite array, the positional parameters? Any time you want to assign the positional parameters, use set. It's as

Re: let's set the positional parameters with a simple 'read'

2012-01-03 Thread jidanni
> "GW" == Greg Wooledge writes: GW> Why not just use a named array? GW> $ read -a myarray But does that let me get a my favorite array, the positional parameters?

Re: let's set the positional parameters with a simple 'read'

2012-01-03 Thread Pierre Gaston
On Tue, Jan 3, 2012 at 7:16 PM, wrote: ... > So I propose we 'wreck the language' to allow me to do > $ read @ > to set $@, same with 1, 2,.. * (almost the same as @). > Since you can use "read -a arr" to set arr[1] arr[2] ...etc it's not that interesting Setting the positional parameters is rea

Re: let's set the positional parameters with a simple 'read'

2012-01-03 Thread Eric Blake
On 01/03/2012 10:16 AM, jida...@jidanni.org wrote: > One can do > $ read p > to set $p > but no just as easy method to set $@, $1, etc. > One must do > $ set -- `cat` #which involves ^D, "too much trouble" > Or set -- `read x; echo "$x"` etc. No need for a subshell to do what you want. Just do:

Re: let's set the positional parameters with a simple 'read'

2012-01-03 Thread Greg Wooledge
On Wed, Jan 04, 2012 at 01:16:27AM +0800, jida...@jidanni.org wrote: > So I propose we 'wreck the language' to allow me to do > $ read @ > to set $@, same with 1, 2,.. * (almost the same as @). Why not just use a named array? $ read -a myarray

let's set the positional parameters with a simple 'read'

2012-01-03 Thread jidanni
One can do $ read p to set $p but no just as easy method to set $@, $1, etc. One must do $ set -- `cat` #which involves ^D, "too much trouble" Or set -- `read x; echo "$x"` etc. No, nothing as easy as $ read 1 sds bash: read: `1': not a valid identifier $ read @ sdss bash: read: `@': not a valid i