Issue #13444 has been updated by dikderoy (Roman Bulgakov).


yes, You are right, it was my mistake to use it in this way, as this example is actually pointless and always True. all meaningful expression (as for ex. 1==Integer(`echo 1`, 10)) are evaluated correctly. Probably you should close and delete this.

----------------------------------------
Bug #13444: compatibility breaking change: backticks is not evalueted as shell script call while in "unless" operator context
https://bugs.ruby-lang.org/issues/13444#change-64303

* Author: dikderoy (Roman Bulgakov)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Ruby versions from 2.0 to 2.3.x while executing shell script via backticks inside of "unless" construction had it executed and evalueted output as condition,
version 2.4 and onwards had condition evaluated as true but script is not executed.

I haven't find any note regarding such change in release-notes for 2.4.0 and 2.4.1

**Steps to reproduce:**

giving following code:

~~~ ruby
unless `touch abc.txt`
  raise 'Error'
end
~~~

**Expected:**

  cwd has a file abc.txt created

**Actual:**

  cwd has no file abc.txt and no exception has been raised

----

**Test-case (with version comparison via rvm)**

file [test.rb]:

~~~ ruby
unless `touch test-#{RUBY_VERSION}`
  raise 'Error'
end

begin
  puts $?.success?
rescue StandardError => e
  puts "rescued:#{e.message}"
end

s = `ls -l test-#{RUBY_VERSION}`
puts s.lines.length == 1 ? 'OK' : 'NOK'
~~~

exec:

**$ rvm list**

~~~ text

  rvm rubies

   ruby-2.0.0-p648 [ x86_64 ]
   ruby-2.1.10 [ x86_64 ]
   ruby-2.2.6 [ x86_64 ]
   ruby-2.3.3 [ x86_64 ]
 * ruby-2.4.0 [ x86_64 ]
=> ruby-2.4.1 [ x86_64 ]
~~~

**$ rvm all --verbose do ruby test.rb** 

~~~ text
ruby-2.1.10: ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-linux] 
true
OK

ruby-2.2.6: ruby 2.2.6p396 (2016-11-15 revision 56800) [x86_64-linux] 
true
OK


ruby-2.0.0-p648: ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux] 
true
OK

ruby-2.3.3: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux] 
true
OK

ruby-2.4.0: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux] 
rescued:undefined method `success?' for nil:NilClass
NOK

ruby-2.4.1: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] 
rescued:undefined method `success?' for nil:NilClass
NOK
~~~

**$ ls -l test-***

~~~ text
-rw-rw-r-- 1 user user 0 ѧ.  17 23:50 test-2.0.0
-rw-rw-r-- 1 user user 0 ѧ.  17 23:50 test-2.1.10
-rw-rw-r-- 1 user user 0 ѧ.  17 23:50 test-2.2.6
-rw-rw-r-- 1 user user 0 ѧ.  17 23:50 test-2.3.3
~~~

**OS:** Ubuntu 14.04
**cat /etc/debian_version:** jessie/sid
**uname -isoprvm:** Linux 3.13.0-116-generic #163-Ubuntu SMP Fri Mar 31 14:13:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


---Files--------------------------------
test.rb (218 Bytes)


-- 
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>