On 8/3/14, 11:02 AM, Tim Friske wrote:
> 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.

Bash creates local variables when local/declare/typeset are used to declare
a variable within a function.  printf -v var [opts] format [args] works
more like

v=$(printf [opts] format [args])

without the subshell or any of the special handling command substitution
receives.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to