I'm trying to use echo
inside a Puppet rule to add a line to .bashrc
, but I can't seem to get the quoting right.
'/usr/bin/echo -E PS1=\"[\t--------------------------------------------------------\n-\u@\h:\W]\$\" >> /home/unu/.bashrc'
This thing gives me the following result:
PS1="[t--------------------------------------------------------n-u@h:W]$"
Another attempt:
'/usr/bin/echo -E PS1="[\t--------------------------------------------------------\n-\u@\h:\W]\$" >> /home/unu/.bashrc'
This thing gives me the following:
PS1=[\t--------------------------------------------------------\n-\u@\h:\W]$
Another one:
'/usr/bin/echo -e PS1="[\\t--------------------------------------------------------\\n-\\u@\\h:\\W]\\$" >> /home/unu/.bashrc'
This one is giving me this:
PS1=[ --------------------------------------------------------
-\u@\h:\W]$
I can't seem to find a way to do this without having \
or "
interpreted in some way. How should I do this?
I thought of using more quotes, but it causes a syntax error from Puppet:
"/usr/bin/echo -e 'PS1="[\\t--------------------------------------------------------\\n-\\u@\\h:\\W]\\$"' >> /home/unu/.bashrc"
Gets this result:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Syntax error at '' (file: /etc/puppetlabs/code/environments/production/modules/profile/manifests/ps1.pp, line: 3, column: 38) on node centoslave1
This is the whole code:
class profile::ps1 {
exec { 'myps1':
command => "/usr/bin/echo -e 'PS1="[\\t--------------------------------------------------------\\n-\\u@\\h:\\W]\\$"' >> /home/unu/.bashrc"
}
}
.bashrc
. – JigglyNaga Sep 20 '18 at 16:09>>
) in the puppet command, you'll need to use theshell
provider . – JigglyNaga Sep 20 '18 at 16:24