I’m trying to update a site generator at work. One of the things that must be done is editing the gitosis.conf file to add the repo to the right group. This is how that block is currently set up in my gitosis.conf file.
[group sites]
writable = site1 site2 site3 randomsite awesomeness
members = @devs
So after countless tries, I’ve made a few “advancements” and then some steps back.
sed -i"" -e"/sites/,\$s/writable.*/& PROJECTNAME/" gitosis.conf
I was finally able to get the code to work on the CentOS command line, but now if I try to run it in irb (running it in a ruby script with backticks, so this has to work) I get this error:
sed: -e expression #1, char 22: unknown command: `&’
=> “”
“char 22” may be incorrect because I’ve edited some of the words a little bit to make the example more vanilla.
This is what is actually in the ruby script.
gitosis = `sed -i"" -e"/sites/,\$s/writable.*/& PROJECTNAME/" gitosis.conf`
I’ve been searching everywhere to try to fix this, but so far I’ve come up with nothing. I’ve read various places that a better option is ruby -pe in order to keep it ruby, but I don’t even know where to start with that. Any advice/input would be awesome. Thank you!
Well you don’t really need to escape the
$variable. Try using this –gitosis =
sed -i"" -e "/70/,/$/s/75/& #{p}/" gitosis.confOR
gitosis =
sed -i"" -e "/70/,$ s/75/& #{p}/" gitosis.confThough I am not too sure what are you planning to do with the variable that you are assigning this
sed one-linerto. Since it is anin-line substitution, you will get a variable with nothing in it.