help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] opposite of 'shift'


From: Chet Ramey
Subject: Re: [Help-bash] opposite of 'shift'
Date: Sat, 18 Feb 2012 16:23:27 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 2/17/12 8:25 AM, Pierre Gaston wrote:
> 
> 
> On Thu, Feb 16, 2012 at 10:56 PM, Dan Douglas <address@hidden
> <mailto:address@hidden>> wrote:
> 
>     On Thursday, February 16, 2012 09:35:28 AM Greg Wooledge wrote:
>     > On Thu, Feb 16, 2012 at 08:26:59AM -0600, Dan Douglas wrote:
>     > > You can't. nonlocal positional parameters are inacceessable.
>     > parameters.  (I gave two example input arrays.)  Sorry for the 
> confusion.
> 
>     Ah, misinterpreted.
> 
>     But for arrays, it's almost worse!
> 
> 
> This is probably because bash lacks an easy way to pass an array by
> reference to a function.

This is where a requested feature could make it into bash.  This seems to
be a common problem with no clean solution (one can only get so far with
eval and ${!param}).

The ksh93 `nameref' (typeset -n) feature would solve this.  It's not really
well documented, and there are many corner cases to catch, but it's not
that hard to implement.  One example: is it a symlink, where it's resolved
at reference time, or a pointer, where the reference is assigned at initial
declaration?  Another set of cases involve the scoping questions if the
first alternative is chosen.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]