0

运行正确:

C:\>ruby -00 -e 'a= gets; puts a ;puts "here is: #{$/.inspect}"'
Hi #[pressed ENTER]
[pressed ENTER]
Hi # <~~ here Hi came as the output, as expected.

here is: "\n\n"  #<~~ here Hi came as the output, as expected.

C:\>

但是当我的 Ubuntu 机器上发生这种情况时,我感到很惊讶:

@ubuntu:~$ ruby -00 -e 'a= gets; puts a ;puts "here is: #{$/.inspect}"'
> hi # [pressed ENTER]
> [pressed ENTER]
> hi #[pressed ENTER]
> ^C
@ubuntu:~$

有什么建议可以让它在 Ubuntu 中运行吗?

4

1 回答 1

2

在 Ubuntu 中对我来说非常好用:

% ruby -00 -e 'a = gets; puts a; puts "here is #{$/.inspect}"'                                                                        
hi

hi

here is "\n\n"

看起来您只是缺少命令中的最后一个单引号。

于 2013-02-14T18:27:42.193 回答