Bug #140

here-doc using backticks around delimiter not specified

Added by Kim Toms 385 days ago. Updated 385 days ago.

Status :Feedback Start :08/19/2009
Priority :Low Due date :
Assigned to :- % Done :

0%

Category :-
Target version :-

Description

It is possible to specify a here-document using backticks('`') around the delimiter. When this is done, the value of the string is the output of the execution of the commands. e.g:

astring = <<`EOF`
echo hello
EOF
astring => "hello\n" 

This operation also sets $?, and that is tested for (although not in the sense of a here-document) in core/kernel/backtick_spec.rb
The rest of the here-document specs are in language/string_spec.rb, so I am not sure where to go to add these specs.

History

08/19/2009 09:40 AM - Brian Ford

  • Status changed from New to Feedback

Hi,

This is a good question, and a confusing situation. Here's how I would break it down:

  • The language specs are for syntax elements. There is language/string_spec.rb that covers using ` (backtick) as a string delimiter with % and also covers heredocs. There is language/execution_spec.rb that covers using ` to execute a system command.
  • But since #` is a method on Kernel, there are also specs in core/kernel/backtick_spec.rb for that method.

I would add the heredoc-as-executable-string to language/execution_spec.rb because it is a syntax element that adds execution to the normal heredoc rather than just delimiting a multiline string.

HTH,
Brian

Also available in: Atom PDF