[TxMt] Re: Command input as a shell variable

Jonathan Clayden jon.clayden at gmail.com
Fri Jul 14 17:14:21 UTC 2006


(smacks head)

Sorry - I'm being very slow. Of course, "read" will do what I want.
Hopefully other R users may find this "Show in R help" command useful
though.

read name
cat `find /Library/Frameworks/R.framework/Versions/Current/Resources/library
-name $name.html -print`


On 14/07/06, Jonathan Clayden <jon.clayden at gmail.com> wrote:
> Hi all,
>
> Previous conversations on related topics to this don't seem to answer
> the question (correct me if I'm wrong!), so:
>
> Can I turn the input to a command script into a shell variable, i.e.
> is there a UNIXy way of reading stdin into a variable?
>
> To be more concrete, I have a simple command for looking up the
> current word in the R help files (which are in HTML) and displaying
> the page in TM's browser. The basic command is
>
> #! /usr/bin/ruby
> text = STDIN.read
> file = `find /Library/Frameworks/R.framework/Versions/Current/Resources/library
> -name #{text}.html -print`
> html = `cat #{file}`
> print html
>
> This works, but seems like an inelegant solution, and for more complex
> tasks it would be useful to know how to avoid needing ruby and make
> this something like
>
> var=[something]
> cat `find /Library/Frameworks/R.framework/Versions/Current/Resources/library
> -name $var.html -print`
>
> TIA!
> Jon
>



More information about the textmate mailing list