summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean Horn <sean_horn@opscode.com>2023-01-24 15:18:49 -0500
committerGitHub <noreply@github.com>2023-01-24 15:18:49 -0500
commitc959be80785915234e47c257d291e5d595780bd6 (patch)
tree590751030ebff5dff666b025547dbd1fbcd9e39d /lib
parent8d9a753e3d8a4f79fbe77f4cf86c87e87e196176 (diff)
downloadchef-c959be80785915234e47c257d291e5d595780bd6.tar.gz
Example of bash resource doubled escape characters (#13509)
* 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>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/resource/bash.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/resource/bash.rb b/lib/chef/resource/bash.rb
index 43f20a75ab..1d06ed8e85 100644
--- a/lib/chef/resource/bash.rb
+++ b/lib/chef/resource/bash.rb
@@ -43,6 +43,19 @@ class Chef
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: