[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug or feature: Why does Bash's "printf" define global variables?
From: |
Tim Friske |
Subject: |
Bug or feature: Why does Bash's "printf" define global variables? |
Date: |
Sun, 3 Aug 2014 17:02:41 +0200 (CEST) |
Hi,
my assumption was that Bash's "printf" builtin implicitly defines a local
variable when used inside a function like so:
function foobar { printf -v foo bar; }
foobar
declare -p foo
# Prints "bar" from the global "foo" variable.
But instead I have to declare the "foo" variable to be a "local" member of
the "foobar" function like so:
unset -v foo
function foobar { local foo=; printf -v foo bar; }
foobar
declare -p foo
# Prints an error message saying that there is no "foo" defined.
Cheers
Tim
- Bug or feature: Why does Bash's "printf" define global variables?,
Tim Friske <=