bug-bash
[Top][All Lists]
Advanced

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

Re: exec, redirections and variable expansions


From: Marc Herbert
Subject: Re: exec, redirections and variable expansions
Date: Tue, 26 Jan 2010 10:02:17 +0000
User-agent: Thunderbird 2.0.0.23 (X11/20090825)

mike bakhterev a écrit :
> 
> Description:
>       Something is wrong with variable substitution in the exec invocation.
>       When i try to close file descriptor whose number is in variable X with
>       command:
> 
>               exec $X>&-

I think the operator is   2>   as a whole; you cannot split the two characters.
Operators are parsed before parameter expansion.

In other words, what you are trying to do is a bit like:

I=i F=f 
# Does not work either!
$I$F true; then echo foo; fi


You need eval:

  eval "$I$F true; then echo foo; fi" # Works
  eval "exec $X>&-"                   # Works





reply via email to

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