[Top][All Lists]

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

Re: Issues with exported functions

From: Gabriel Corona
Subject: Re: Issues with exported functions
Date: Thu, 25 Sep 2014 12:24:36 +0200
User-agent: Mutt/1.5.23 (2014-03-12)


As the interface is not specified, would it make sense to:

 * add a prefix (use BASH_FUNCTION_foo instead of foo for exported
   function foo);

 * still expand the variable if it matches the 'exported function'

The first point would reduce the probability of a clash with
a user variable:

  foo() {
    echo Executing function "$@"

  export -f foo
  export foo
  bash -c foo
  # OK
  bash -c 'echo $foo'
  # OK as well
  bash -c env
  # In fact the environment variable is set twice, I didn't know it was event 
  dash -c 'echo $foo'
  # Dash find the second one: () { echo Executing function "$@" }

The second (more important) point would allow a variable to begin with
"() {}" or similar:

  # I'm not aware of the function export feature
  # or x comes from somewhere else:
  $ x="() {}"  bash -c 'echo $x' 2>/dev/null
  $ x="() {}"  dash -c 'echo $x' 2>/dev/null
  () {}


reply via email to

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