0

I have a cookbook that delivers a number of bash shell scripts as cookbook_file resources. For some reason when I run chef-client, the bash shell scripts will suddenly gain a carriage return as the very last character. On my windows box, the shell scripts have Linux style line endings and the .gitattributes file contains an entry that indicates that .sh files should upload/download with Linux style line endings.

I have confirmed that this unwanted carriage return character arrives sometime between "berks upload" and "chef-client".

Ultimately this prevents bash from executing the bash scripts.

How do I prevent this from happening?

0

It appears that Chef acknowledges that it's pretty terrible in dealing with line endings and provides no means to specify what to do with them[1].

To work around it, exit statements followed by a new line has been added to all of the bash scripts in the cookbook. This allows the script to exit before bash runs into the bad character.

[1] https://github.com/chef/chef/issues/4662

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.