simple pipe : `echo -n "#{@prefix}" | pbcopy`

U

Une Bévue

@prefix is a string i want to put on the pasteboard (Mac OS X)

if from zsh :
echo -n "${prefix}" | pbcopy
this works well, i get the prefix in the pasteboard.

if from ruby :
`echo -n "#{@prefix}" | pbcopy`
instead of getting @prefix, i get :
-n @prefix\n

with an ending return i wanted to avoid with the "-n" arg to echo.
 
R

Robert Klemme

@prefix is a string i want to put on the pasteboard (Mac OS X)

if from zsh :
echo -n "${prefix}" | pbcopy
this works well, i get the prefix in the pasteboard.

if from ruby :
`echo -n "#{@prefix}" | pbcopy`
instead of getting @prefix, i get :
-n @prefix\n

with an ending return i wanted to avoid with the "-n" arg to echo.

You cannot open a pipe like this. Try

IO.popen(["pbcopy"], "w+") do |io|
io.write @prefix
io.close_write
IO.copy_stream(io, $stdout)
end

Kind regards

robert
 
U

Une Bévue

Le 29/05/13 20:14, Robert Klemme a écrit :
You cannot open a pipe like this. Try

IO.popen(["pbcopy"], "w+") do |io|
io.write @prefix
io.close_write
IO.copy_stream(io, $stdout)
end

Fine thanks, that works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top