Differences

This shows you the differences between two versions of the page.

Link to this comparison view

programming [2017/08/24 09:24]
dlicious Initial page with Python warning configuration
programming [2018/04/09 11:11] (current)
dlicious Added section on indirect variables in POSIX shells
Line 18: Line 18:
 warnings.warn("Something isn't quite right, but we don't have to abort over it.") warnings.warn("Something isn't quite right, but we don't have to abort over it.")
 warnings.warn("Something isn't quite right, but we don't have to abort over it.", UserWarning, stacklevel=1) warnings.warn("Something isn't quite right, but we don't have to abort over it.", UserWarning, stacklevel=1)
 +</code>
 +
 +====== Indirect variables in shell scripts ======
 +
 +Normally, you'd use an associative array for this (including BASH) instead of manually embedding a variable in another variable, but this solution works in POSIX environments like regular Bourne shell (and BASH's emulation of it):
 +
 +<code bash>
 +favorite_color_joe=gold
 +favorite_color_jane=blue
 +
 +person=${1}
 +
 +target_interface=`eval echo \$favorite_color_${person}`
 </code> </code>
programming.txt · Last modified: 2018/04/09 11:11 by dlicious
 
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Run by Debian Driven by DokuWiki