<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Nested Shell</title><link>https://sourceforge.net/p/bashdb/wiki/Nested%2520Shell/</link><description>Recent changes to Nested Shell</description><atom:link href="https://sourceforge.net/p/bashdb/wiki/Nested%20Shell/feed" rel="self"/><language>en</language><lastBuildDate>Sun, 14 Dec 2014 03:20:54 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/bashdb/wiki/Nested%20Shell/feed" rel="self" type="application/rss+xml"/><item><title>Nested Shell modified by Rocky Bernstein</title><link>https://sourceforge.net/p/bashdb/wiki/Nested%2520Shell/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,4 +1,4 @@
-lthough the debugger allows one to evaluate arbitrary _bash_ code using the debugger _eval_ command or the __set autoeval__ mode, sometimes you might prefer to work inside a _bash_ shell to see variables, experiment, issue commands (using the currently-set up environment), and even change variables and functions.
+Although the debugger allows one to evaluate arbitrary _bash_ code using the debugger _eval_ command or the __set autoeval__ mode, sometimes you might prefer to work inside a _bash_ shell to see variables, experiment, issue commands (using the currently-set up environment), and even change variables and functions.

 For this we, the debugger _shell_ command, enters a nested shell session. But before it does this, it saves out variable and function definitions in the current context of the running program. That way, you have access to those. 

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rocky Bernstein</dc:creator><pubDate>Sun, 14 Dec 2014 03:20:54 -0000</pubDate><guid>https://sourceforge.net190b66253e725656edc03a8b5d832f44e7044d7d</guid></item><item><title>Nested Shell modified by Rocky Bernstein</title><link>https://sourceforge.net/p/bashdb/wiki/Nested%2520Shell/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;lthough the debugger allows one to evaluate arbitrary &lt;em&gt;bash&lt;/em&gt; code using the debugger &lt;em&gt;eval&lt;/em&gt; command or the &lt;strong&gt;set autoeval&lt;/strong&gt; mode, sometimes you might prefer to work inside a &lt;em&gt;bash&lt;/em&gt; shell to see variables, experiment, issue commands (using the currently-set up environment), and even change variables and functions.&lt;/p&gt;
&lt;p&gt;For this we, the debugger &lt;em&gt;shell&lt;/em&gt; command, enters a nested shell session. But before it does this, it saves out variable and function definitions in the current context of the running program. That way, you have access to those. &lt;/p&gt;
&lt;p&gt;This however creates a new problem: getting changes you make reflected back into the running program. Right now any variable you change can be flagged to have its value re-read when the shell exits. This is done using the &lt;em&gt;save_var&lt;/em&gt; function inside the nested shell. &lt;em&gt;save_var&lt;/em&gt; takes a list of variable names. &lt;/p&gt;
&lt;p&gt;Here is an example session&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;bashdb /etc/init.d/apparmor status
bashdb debugger, release 0.9

Copyright 2008-2011, 2014 Rocky Bernstein
...
&lt;span class="o"&gt;(&lt;/span&gt;/etc/init.d/apparmor:35&lt;span class="o"&gt;)&lt;/span&gt;:
. /etc/apparmor/functions
bashdb&amp;lt;1&amp;gt; s
&lt;span class="o"&gt;(&lt;/span&gt;/etc/apparmor/functions:24&lt;span class="o"&gt;)&lt;/span&gt;:
&lt;span class="nv"&gt;PROFILES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/etc/apparmor.d"&lt;/span&gt;
bashdb&amp;lt;2&amp;gt; s
&lt;span class="o"&gt;(&lt;/span&gt;/etc/apparmor/functions:25&lt;span class="o"&gt;)&lt;/span&gt;:
&lt;span class="nv"&gt;PARSER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/sbin/apparmor_parser"&lt;/span&gt;
bashdb&amp;lt;3&amp;gt; shell
bashdb &lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;typeset&lt;/span&gt; -p PROFILES
&lt;span class="nb"&gt;typeset &lt;/span&gt;&lt;span class="nv"&gt;PROFILES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/etc/apparmor.d
bashdb &lt;span class="nv"&gt;$ PROFILES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Hi, Mom!'&lt;/span&gt;
bashdb &lt;span class="nv"&gt;$ &lt;/span&gt;save_vars PROFILES
bashdb &lt;span class="nv"&gt;$ &lt;/span&gt; &amp;lt;EOF&amp;gt;
&lt;span class="o"&gt;(&lt;/span&gt;/etc/apparmor/functions:25&lt;span class="o"&gt;)&lt;/span&gt;:
&lt;span class="nv"&gt;PARSER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/sbin/apparmor_parser"&lt;/span&gt;
bashdb&amp;lt;4&amp;gt; x PROFILES
&lt;span class="nb"&gt;typeset &lt;/span&gt;&lt;span class="nv"&gt;PROFILES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Hi, Mom!'&lt;/span&gt;
bashdb&amp;lt;5&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note that inside the nested shell the we have set the prompt has been set to: &lt;em&gt;bashdb $&lt;/em&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rocky Bernstein</dc:creator><pubDate>Sun, 14 Dec 2014 03:20:29 -0000</pubDate><guid>https://sourceforge.net7b7db33dc0c0988a3a79690fb629967ce507a359</guid></item></channel></rss>