Re: Negative array subscript with unset

2011-03-12 Thread Chet Ramey
On 3/12/11 7:21 PM, Chris F.A. Johnson wrote:
> 
>   I all versions I have tried, unsetting an array element using a
>   negative index fails:
> 
> $ array=( q w e r t y )
> $ unset 'array[-1]'
> bash: [-1]: bad array subscript

Negative subscripts only work with ${parameter[subscript]}.  The problem
is that I put the text in the manual page describing their use in the
wrong place.  It should have gone in the paragraph describing array
references.

Negative subscripts will work in more contexts in the next version of bash.

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



Re: Negative array subscript with unset

2011-03-12 Thread Dennis Williamson
On Sat, Mar 12, 2011 at 6:21 PM, Chris F.A. Johnson
 wrote:
>
>  I all versions I have tried, unsetting an array element using a
>  negative index fails:
>
> $ array=( q w e r t y )
> $ unset 'array[-1]'
> bash: [-1]: bad array subscript
>
>
> --
>   Chris F.A. Johnson, 
>   Author:
>   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
>   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
>
>

Assignments to negative indices don't work either. (Bash 4.2)

-- 
Visit serverfault.com to get your system administration questions answered.



Negative array subscript with unset

2011-03-12 Thread Chris F.A. Johnson


  I all versions I have tried, unsetting an array element using a
  negative index fails:

$ array=( q w e r t y )
$ unset 'array[-1]'
bash: [-1]: bad array subscript


--
   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: Hightlighting in bash

2011-03-12 Thread Derek Fawcus
On Thu, Mar 10, 2011 at 11:53:22AM -0800, Micah Cowan wrote:
> 
> It wouldn't be difficult to write as a separate program, which is really
> how this should be handled. You could redirect a pipeline's STDOUT and
> STDERR to individual named pipes (FIFOs), and have a separate program
> read from both pipes, inserting highlights around any data it copies
> from the STDERR pipe.

I cobbled up such a program (or pair of programs in the case) a while ago.
It'd run stdin & stdout through a pty,  and stderr through a seperate FIFO.

I'd then run a shell within this environment.  One thing I found wrt the
version of bash being used was that it would not enable job control.

It seems bash wanted stderr to be a pty as well,  however a simple change
removed that limitation in bash.

.pdf