Dato un esempio di script che si apre /dev/tty
:/dev/tty si apre in nailgun-terminal server
# sample.rb
tty=File.open("/dev/tty", "w+")
tty.print "> "
tty.puts tty.gets.upcase
posso eseguirlo con JRuby normale bene:
% jruby sample.rb
> hello
HELLO
%
Tuttavia, se provo da utilizzare con /dev/tty
nailgun, allora la tty è legato al server nailgun, non il cliente:
# server terminal | # client terminal
% jruby --ng-server |
NGServer 0.9.1 started on all interfaces, port 2113. |
| % jruby --ng sample.rb
> hello |
HELLO |
| %
(la spaziatura verticale è per mostrare i tempi, l'uscita effettiva per ciascuna manca le righe vuote)
È questo comportamento previsto o un errore?
Se ci si aspetta un comportamento, c'è un modo che posso rilevare se uno script viene eseguito con --ng
così posso evitare aperture /dev/tty
?