[Top][All Lists]

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

exec, redirections and variable expansions

From: mike bakhterev
Subject: exec, redirections and variable expansions
Date: Mon, 25 Jan 2010 18:32:25 +0500

From: mike
To: address@hidden
Subject: [50 character or so descriptive subject here (for reference)]

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include
-I./lib   -march=x86-64 -mtune=generic -O2 -pipe
uname output: Linux 0x01 2.6.32-ARCH #1 SMP PREEMPT Sat Jan 23
11:41:48 CET 2010 x86_64 AMD Phenom(tm) 9550 Quad-Core Processor
AuthenticAMD GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.0
Patch Level: 35
Release Status: release

        Something is wrong with variable substitution in the exec invocation.
        When i try to close file descriptor whose number is in variable X with

                exec $X>&-

        Bash reports:

                 exec: NUMBER: not found

        where NUMBER is number of file discriptor. The error occurs when bash
        is used as interperter, and is not emerge when the commands are
        beeing entered in shell.

        When i directly write some file discriptor in the command in some
        script everything works fine:

                exec 2>&- # success
                exec $x>&- # failure


        sh -c 'x=2; exec $x>&-'

reply via email to

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