Fabric: Use Bash Shell for Local Command
July 24, 2015
I love the fabric python library for project deployment and administration tasks. Its default of using /bin/sh as the shell for the “local()” function seems to be causing people some grief. Luckily, fabric gives you the option to set the desired shell, but it can be a pain to do for each local() command. Here’s a quick work around:
1 from fabric.api import local as local_cmd # import local with alternate name
2
3 # create new local command, with the shell set to /bin/bash
4 def local(command_string):
5 local_cmd(command_string, shell="/bin/bash")
6
7 # use your function
8 local("ls -al")