Re: setvalue builtin command

2013-04-09 Thread konsolebox
On Mon, Apr 8, 2013 at 9:05 PM, Greg Wooledge wrote: > On Fri, Apr 05, 2013 at 09:15:10AM +0800, konsolebox wrote: > > The only thing left here is that we can't have error control like when we > > are to create generally shared library scripts e.g.: > > > > function lib_something { > > declar

Re: setvalue builtin command

2013-04-08 Thread Greg Wooledge
On Mon, Apr 08, 2013 at 10:32:40AM -0400, Chet Ramey wrote: > One clarification: a variable is unset unless it has had a value assigned. > There might be some placeholder there with some type information, but the > variable is unset. There might be some inconsistencies in how bash treats > such va

Re: setvalue builtin command

2013-04-08 Thread Chet Ramey
On 4/8/13 9:05 AM, Greg Wooledge wrote: > If the upstream > variable has a value assigned, then you can; but if it's empty, then you > can't. One clarification: a variable is unset unless it has had a value assigned. There might be some placeholder there with some type information, but the variabl

Re: setvalue builtin command

2013-04-08 Thread Greg Wooledge
On Fri, Apr 05, 2013 at 09:15:10AM +0800, konsolebox wrote: > The only thing left here is that we can't have error control like when we > are to create generally shared library scripts e.g.: > > function lib_something { > declare -n VAR=$1 &>/devnull || { # error message is not suppressed >

Re: setvalue builtin command

2013-04-04 Thread konsolebox
The only thing left here is that we can't have error control like when we are to create generally shared library scripts e.g.: function lib_something { declare -n VAR=$1 &>/devnull || { # error message is not suppressed : can_t go here if referred variable's name is invalid ret

Re: setvalue builtin command

2013-04-04 Thread konsolebox
On Thu, Apr 4, 2013 at 9:21 PM, Greg Wooledge wrote: > imadev:~$ stuffit() { declare -n array="$1"; array[thing]=foobar; } Checked my test script and I actually added -A to declare in the process sorry. It's working now thanks. Ross

Re: setvalue builtin command

2013-04-04 Thread Greg Wooledge
On Thu, Apr 04, 2013 at 09:11:49PM +0800, konsolebox wrote: > On second thought I think we still need the function since for declare -n: > > a) Reference variable could not be an array. I'm not sure what you mean. But namerefs may point to arrays or associative arrays in the caller's context. A

Re: setvalue builtin command

2013-04-04 Thread konsolebox
On Thu, Apr 4, 2013 at 8:51 PM, konsolebox wrote: > Another "feature" of this kind of construct is that you can put the name >> of the variable-to-be-assigned into another variable: >> >> ptr=some_variable >> setvalue "$ptr" "$foo" >> >> Which may be a good thing or a bad thing, but either way it

Re: setvalue builtin command

2013-04-04 Thread konsolebox
> > Another "feature" of this kind of construct is that you can put the name > of the variable-to-be-assigned into another variable: > > ptr=some_variable > setvalue "$ptr" "$foo" > > Which may be a good thing or a bad thing, but either way it's definitely > a thing that someone will (ab)use if it'

Re: setvalue builtin command

2013-04-04 Thread Greg Wooledge
On Thu, Apr 04, 2013 at 02:26:34AM -0500, Dan Douglas wrote: > > On Wed, Feb 6, 2013 at 11:30 AM, konsolebox wrote: > > > Hi. I was wondering if we could add a builtin where we could use it as an > > > alternative for assigning values to a parameter. And thought of a builtin > > > name called setv

Re: setvalue builtin command

2013-04-04 Thread konsolebox
On Thu, Apr 4, 2013 at 3:26 PM, Dan Douglas wrote: > On Wednesday, April 03, 2013 11:53:48 PM konsolebox wrote: > > Hi. I made a post on this before but I haven't got a reply. I actually > want > > to know what people think about the idea as I actually find a command > like > > this really helpfu

Re: setvalue builtin command

2013-04-04 Thread Dan Douglas
On Wednesday, April 03, 2013 11:53:48 PM konsolebox wrote: > Hi. I made a post on this before but I haven't got a reply. I actually want > to know what people think about the idea as I actually find a command like > this really helpful. Anyone please? > > On Wed, Feb 6, 2013 at 11:30 AM, konsolebo

Re: setvalue builtin command

2013-04-04 Thread konsolebox
Hi. I made a post on this before but I haven't got a reply. I actually want to know what people think about the idea as I actually find a command like this really helpful. Anyone please? On Wed, Feb 6, 2013 at 11:30 AM, konsolebox wrote: > Hi. I was wondering if we could add a builtin where we c