Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>EDIT - As it turns out, this was fixed in Fabric 1.4.4. From the changelog:</p> <blockquote> <p>[Feature] <a href="https://github.com/fabric/fabric/issues/725">#725</a>: Updated local to allow override of which local shell is used. Thanks to Mustafa Khattab.</p> </blockquote> <p>So the original question would be fixed like this:</p> <pre><code>def test(): local('c', shell='/bin/bash') </code></pre> <p>I've left my original answer below, which only relates to Fabric version &lt; 1.4.4.</p> <hr> <p>Because local doesn't use bash. You can see it clearly in your output</p> <pre><code>/bin/sh: c: command not found </code></pre> <p>See? It's using <code>/bin/sh</code> instead of <code>/bin/bash</code>. This is because Fabric's <code>local</code> command behaves a little differently internally than <code>run</code>. The <code>local</code> command is essentially a wrapper around the <code>subprocess.Popen</code> python class.</p> <p><a href="http://docs.python.org/library/subprocess.html#popen-constuctor">http://docs.python.org/library/subprocess.html#popen-constuctor</a></p> <p>And here's your problem. Popen defaults to <code>/bin/sh</code>. It's possible to specify a different shell if you are calling the Popen constructor yourself, but you're using it through Fabric. And unfortunately for you, Fabric gives you no means to pass in a shell, like <code>/bin/bash</code>.</p> <p>Sorry that doesn't offer you a solution, but it should answer your question.</p> <p>EDIT</p> <p>Here is the code in question, pulled directly from fabric's <code>local</code> function defined in the <code>operations.py</code> file:</p> <pre><code>p = subprocess.Popen(cmd_arg, shell=True, stdout=out_stream, stderr=err_stream) (stdout, stderr) = p.communicate() </code></pre> <p>As you can see, it does NOT pass in anything for the executable keyword. This causes it to use the default, which is /bin/sh. If it used bash, it'd look like this:</p> <pre><code>p = subprocess.Popen(cmd_arg, shell=True, stdout=out_stream, stderr=err_stream, executable="/bin/bash") (stdout, stderr) = p.communicate() </code></pre> <p>But it doesn't. Which is why they say the following in the documentation for local:</p> <blockquote> <p>local is simply a convenience wrapper around the use of the builtin Python subprocess module with shell=True activated. If you need to do anything special, consider using the subprocess module directly.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload