bug-bash
[Top][All Lists]
Advanced

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

Uxexpected complaint of "unbound variable"


From: James Caccese
Subject: Uxexpected complaint of "unbound variable"
Date: Tue, 5 May 2015 01:03:47 +0000 (UTC)

I posted the following question to stackoverflow (http://stackoverflow.com/questions/30042157/why-cant-i-use-declare-r-inside-a-function-fo-mark-a-variable-readonly-while) and was advised the behavior I was witnessing was a bug in bash.

With GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu),
#! /bin/bash
set -u

exec {FD1}>tmp1.txt
declare -r FD1
echo "fd1: $FD1"       # why does this work,

function f1() {
  exec {FD2}>tmp2.txt
  readonly FD2
  echo "fd2: $FD2"     # this work,
}

f1

function f2() {
  exec {FD3}>tmp3.txt
  echo "fd3: $FD3"     # and even this work,
  declare -r FD3
  echo "fd3: $FD3"     # when this complains: "FD3: unbound variable"?
}

f2
Is this an actual bug, or am I missing something?

-James

reply via email to

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