#7 ✓resolved
Trevor Turk

push_text should support single quotes

Reported by Trevor Turk | August 5th, 2009 @ 05:58 AM

Something funny I noticed... the push_text installer doesn't to play well with single quotes, as it seems to remove them. The following hack appears to solve the problem. I could put together a patch if you like, but I thought I'd run it by you first.

module Sprinkle
module Installers

class PushText < Installer
  def install_commands #:nodoc:
    text = @text.gsub("'", "'\\\\''").gsub("\n", '\n') # crazy escaping to allow single quotes
    "echo -e '#{text}' |#{'sudo' if option?(:sudo)} tee -a #{@path}"

end end


Comments and changes to this ticket

  • crafterm

    crafterm August 6th, 2009 @ 10:01 AM

    Hi Trevor,

    Wow, interesting behaviour for sure, if this is working fine for you, a patch and spec for it would be great mate - able to send me a pull request?

    Thanks for finding this out and letting me know mate, much appreciated.



  • Trevor Turk

    Trevor Turk August 7th, 2009 @ 07:21 AM

    Hi Marcus,

    I'm really sorry, but I can't figure out a way to test for this with your specs. I've just removed the use of single quotes from my scripts for now, because I'm not sure if it's a problem specific to my environment or something.

    You are testing for a single quote, but testing the command that gets sent up to the server isn't catching the problem. I've also noticed that backslashes don't seem to work, either. If this is correct, I think we might want to track down why these characters are being lost, and to see if there are any other characters that might be lost as well.

    Perhaps you could test the behavior with a server of yours? This would at least help confirm that this is a general problem. Here's something that demonstrates the issue on my end:

    package :push_text_test do
    config_file = '~/push_text_test' config_text <<-EOF '/hello' EOF

    push_text config_text, config_file end

    ...then if I ssh in and view the contents of the file: root@...:~# cat push_text_test

    ...when I would expect: root@...:~# cat push_text_test

    Let me know what you think. I'm happy to help any way I can, but I'm a bit out of my league on this.

    - Trevor

  • Trevor Turk

    Trevor Turk August 7th, 2009 @ 07:22 AM

    I did a gist up with the code, because this lighthouse formatting is bogus :)


  • Trevor Turk

    Trevor Turk August 12th, 2009 @ 02:13 AM

    I've created a fork that fixes the single quotes issue. It looks like the backslash issue was a misunderstanding on my end about string escaping in heredocs. So, this patch fixes the issue in sprinkle. I'll also send you a pull request. Thanks!


  • Trevor Turk

    Trevor Turk August 12th, 2009 @ 03:43 AM

    As a curiosity (maybe for your readme?) here's a working push_text example:


    Let me know what you think of all this. Thanks!

  • crafterm

    crafterm August 12th, 2009 @ 12:01 PM

    • State changed from “new” to “resolved”

    Thanks - patch merged into master!



Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Sprinkle is a software provisioning tool you can use to build remote servers with, after the base operating system has been installed. For example, to install a Rails or Merb stack on a brand new slice directly after its been created.

People watching this ticket