bash: declare

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

Documented in the 'SHELL BUILTIN COMMANDS' section of man bash or here:
http://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html

#!/bin/bash

function assign {
  # -g makes the variable global.
  declare -g $1=$2
}

assign my_var 42
echo $my_var