[Top][All Lists]

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

Re: eval

From: Greg Wooledge
Subject: Re: eval
Date: Wed, 4 May 2011 08:19:22 -0400
User-agent: Mutt/

On Tue, May 03, 2011 at 09:41:28PM -0500, Jonathan Nieder wrote:
> Rafael Fernandez wrote:
> >         set -- a b c d e f g h i j k l m n o p q r s t u v w x y z
> >         i=1
> >         eval echo '$'$i         # outputs an expected 'a'

I didn't see the original question yet, but it looks like you're trying
to retrieve the Nth positional parameter where N is stored in a variable.
There are two ways to do that in bash, without using eval:

echo "${!i}"

echo "${@:i:1}"

These are bashisms; that is, they do not work in shells that only
implement the POSIX feature set.

reply via email to

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