0

The was running correctly:

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

But I was surprised when this happens on my Ubuntu machine:

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

Any suggestions what to do to make it work in Ubuntu also?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317

1 Answers1

2

Works perfectly fine for me in Ubuntu:

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

hi

here is "\n\n"

Looks like you're just missing the last single quote in the command.

BaronVonBraun
  • 4,285
  • 23
  • 23
  • `ruby -015 -e 'a= gets; puts a ;puts "here is: #{$/.inspect}"'` could you try this? – Arup Rakshit Feb 14 '13 at 18:32
  • In that case, pressing enter does nothing because it's not generating a carriage return. However, if I use `ctrl-v`,`ctrl-m` to generate a \r, it works: `hello ^M hello here is: "\r" ` – BaronVonBraun Feb 14 '13 at 18:38
  • Could you tell me the source of this? what control key is for what ? I have many more to test. – Arup Rakshit Feb 14 '13 at 18:48
  • All I did was Google how to generate a carriage return, found out it was `ctrl-v`,`ctrl-m`. Tried it, it worked. – BaronVonBraun Feb 14 '13 at 18:50
  • Okay....... could you give me the link where you found that `ctrl-m` please, I am goggling for `backspace` not getting the correct one. I have to run the `ruby -010 -e 'a= gets; puts a ;puts "here is: #{$/.inspect}"'` – Arup Rakshit Feb 14 '13 at 18:54
  • http://stackoverflow.com/questions/7742340/how-to-add-a-carriage-return-as-a-character-to-a-file, the accepted answer. Unfortunately has nothing to do with what you're looking for now. But, I'm sure you'll find what you need if you keep looking. – BaronVonBraun Feb 14 '13 at 18:56