Issue #14385 has been updated by shevegen (Robert A. Heiler).


> In Bash $() is prefered over backticks for that reason.

Bash uses horrible things such as tapping into arguments
within a function without that function having a proper
method signature. I do not think it is useful to want to
compare ruby to e. g. bash - there are world's apart. One
is designed (ruby); and one is a mess (bash and shell 
scripts in general).

> How would you express such a call with backticks without ambiguities

> foo=$(echo $(whoami))
> echo $foo

I am not sure how this relates to ruby.

I think we have to separate here between different things. Matz wants
to change this - ok.

I think the proper way would be to add a deprecation warning for the
next release, before then changing it for ruby 3.0 (if it is decided
to change it).

This change will require quite some changes in ruby users code. I used
backticks quite a lot. I am not sure if I want to use %x{} as a
replacement though. To me these two are not synonymous. `` is so 
much easier to use than %x( ). I also have to remember the "x".

In my ruby code I tend to use `` quite a bit, with a trailing "2>&1".

I used this for example in a ruby script that queries which versions
of gcc, glibc, binutils, coreutils, sed, awk etc... are available,
and then report these findings to the user. I found that `` + the
redirection part works very well here.

It's possible to adapt all my ruby code, possibly within a single day;
I only have to grep a little then replace. It is not a big deal. But
I am not sure if I like the equivalent %x( ) - it just does not carry
as much as light a message as the `` did, so I am not sure yet what I
may use instead. system() is also of no help here since I need to 
capture the output, and possibly modify it. Using the popen* variants
is unfortunately way too cumbersome, and one has to do a require 
step, which I don't think is ideal (see how require 'pp' became
optional, which I think is great).

In another project I needed even more control than with `` and in that
project I opted to use something like this:

    IO.popen(i, {:err => [:child, :out]}).each { |line|

I think also tend to modify the line, e. g. colourize it and stuff,
before displaying it to the ruby user at hand. It's a lot more 
cumbersome to use than `` and %x() but one redeeming feature of
that is that I have more control about what is going to happen.

I do not really have any big pro or con opinion as such, even if
I am slightly sceptical about the trade off, but I can adjust -
I think it is important to put timely deprecation notices in place
IF it is decided to change this, though. I estimate that several
ruby users will have to change their code - backticks are used
quite a bit out there "in the wild".


----------------------------------------
Feature #14385: Deprecate back-tick for Ruby 3.
https://bugs.ruby-lang.org/issues/14385#change-78951

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
From https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20171212Japan#From-attendees

Matz hopes to deprecate backtick syntax(``) for Ruby 3. We should warn about it at Ruby 2.6 (or 2.7?)

We need to consider them.

* warning message
* warning level
* ?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>