Skip to content

Commit

Permalink
Example of bash resource doubled escape characters (#13509)
Browse files Browse the repository at this point in the history
* Example of doubled

Let's show an example of doubled escape characters.

The chef-client bash interpreter gets one, and find gets one.

Signed-off-by: Sean Horn <sean_horn@opscode.com>
Co-authored-by: Ian Maddaus <IanMadd@users.noreply.github.com>
  • Loading branch information
sean-horn and IanMadd committed Jan 24, 2023
1 parent 8d9a753 commit c959be8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/chef/resource/bash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ class Bash < Chef::Resource::Script
end
```
**Using escape characters in a string of code**
In the following example, the `find` command uses an escape character (`\`). Use a second escape character (`\\`) to preserve the escape character in the code string:
```ruby
bash 'delete some archives ' do
code <<-EOH
find ./ -name "*.tar.Z" -mtime +180 -exec rm -f {} \\;
EOH
ignore_failure true
end
```
**Install a file from a remote location**
The following is an example of how to install the foo123 module for Nginx. This module adds shell-style functionality to an Nginx configuration file and does the following:
Expand Down

0 comments on commit c959be8

Please sign in to comment.