How do I capture the output of @code_llvm in a variable?

I want to capture it so I can open it in a pager:

function more(content::AbstractString)
    run(pipeline(`echo $(content)`, `less`))
    nothing
end
more(@code_llvm sth())

This might help:

1 Like

Use the function instead Interactive Utilities · The Julia Language. In particular, the io argument.

Also, it’s not a good idea to use echo. You should just use an IOBuffer instead.

6 Likes