There $?is an instance in Ruby Process::Status. Printing is $?equivalent to a call $?.to_s, which is equivalent $?.to_i.to_s(from the documentation).
to_idoes not match with exitstatus.
From the documentation:
Posix 16- . (, , ) , , ( ).
$?.to_i 16- , , , , exitstatus:
$?.exitstatus