fabric/fabric — pull request #567 by mviera (2012-02-24 11:16:29+00:00)
Title: Bug when scaping quotes in sed

Hi,

It seems there is a bug in sed when trying to escape quotes. I tried to replace 'HOST': '' to 'HOST': 'ip-address' and sed throws the following error:

[192.168.11.142] sudo: sudo -S -p 'sudo password:' sed -i.bak -r -e 's/\'HOST\': \'\'/\'HOST\': \'192.168.11.142\'/g' /home/user/settings.py

Fatal error: sudo() received nonzero return code 1 while executing!

Requested: sed -i.bak -r -e 's/\'HOST\': \'\'/\'HOST\': \'192.168.11.142\'/g' /home/user/settings.py
Executed: sudo -S -p 'sudo password:' sed -i.bak -r -e 's/\'HOST\': \'\'/\'HOST\': \'192.168.11.142\'/g' /home/user/settings.py

None

================== Standard output ======================================

bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file

=====================================================================

It seems the best way to escape quotes in bash is the following: '\''

I already have sed working fine so I'm looking forward to find this fix accepted.

Cheers,
Manuel Viera.