New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exec and Bash vars, false-postive "single quoted string containing a variable found on line" #113
Comments
I am also seeing this issue with the command parameter for cron resources. |
Unfortunately this isn't as simple as the description suggests. A class that I have defined has a parameter that may take bash variables. So simply ignoring command, onlyif and unless statements won't do the complete job. |
Since this issue is still open and a similar one was closed, I'll add my comments here, even though it is a rather old ticket. [1] #189 |
I created pull #234 changing @andreashaerter example around to use double quotes should work now class foobar() {
# wrong behavior
# puppet-lint detects the Bash var ${FOOBAR} and reports
# "ERROR: single quoted string containing a variable found on line"
exec{ 'wrong single quoted string containing a variable':
command => "set -e; set -u;
FOOBAR=\'this is a Bash var\';
echo \"Bash: \${FOOBAR}\";",
path => [ '/usr/local/bin', '/sbin', '/bin', '/usr/sbin', '/usr/bin' ],
provider => 'shell',
logoutput => true,
}
} |
Not really. It's a bash variable, but it looks like a Puppet variable. We can still use double quotes and escape the $. rodjek/puppet-lint#113 ERROR: single quoted string containing a variable found on line 3
(CONT-811) Add Ruby 3.2 support
puppet-lint detects Bash vars in single quoted strings and reports "single quoted string containing a variable found on line".
The following example shows the problem:
I don't know any Ruby nor the puppet-lint internals. And I see that the basic problem is: Bash uses the same variable syntax as Puppet. So searching for Puppet vars in exec command/onlyif/unless will find Bash vars.
Therefore the only quick idea I got to solve/soften this problem is to adjust the "single quoted string containing a variable found on line" error check:
As puppet-lint is able to detect 'top-scope variable being used without an explicit namespace' there already seems to be some intelligence regarding Puppet vars in strings. Maybe a comparable procedure is able to solve the false-positive-bash-var errors.
The text was updated successfully, but these errors were encountered: