Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
braincrash has quit [Ping timeout: 264 seconds]
dionysus69 has joined #ruby
_whitelogger has joined #ruby
davispuh has joined #ruby
davispuh has quit [Ping timeout: 272 seconds]
dionysus69 has quit [Ping timeout: 260 seconds]
Rudd0 has quit [Ping timeout: 265 seconds]
drincruz has joined #ruby
ellcs has joined #ruby
TCZ has joined #ruby
drincruz has quit [Ping timeout: 265 seconds]
johndotpub has quit [Quit: /dev/zero]
johndotpub has joined #ruby
greengriminal has joined #ruby
hiroaki has joined #ruby
ellcs has quit [Ping timeout: 240 seconds]
greengriminal has quit [Quit: Leaving]
Nahra has joined #ruby
<isene>
Writing a file manager. I want to change the working directory of the parent process (the shell where the file manager was launched) to the directory that the user navigated to in the file manager. I know this is not generally possible within ruby, but I suspect there is some trick I can do... but how?
<jhass>
I don't think it's possible at all
<jhass>
maybe you can make your program print the directory and have a shell function that does cd $(your_program), but that's still quite ugly
ellcs has joined #ruby
ellcs has quit [Ping timeout: 260 seconds]
supercoven has quit [Ping timeout: 240 seconds]
<isene>
jhass: Any ugly will do
semz has joined #ruby
<semz>
Is there a detailed document about Marshal's format somewhere? I'm writing a parser for (a pretty large subset of) it and have considerable trouble nailing down the exact behavior of the object/symbol caches.
<isene>
So, I source a script in my zsh that launches the said file manager. Now, how do I make that script respond to my ruby program doing ' puts Dir.pwd ' ? Or should I print the pwd to some other place where the parent script can catch it?
<jhass>
isene: you want to change it while the subprogram is running? Why?
jmcgnh has quit [Ping timeout: 246 seconds]
<isene>
No - I want to cd to a desired location when the program exits - but I need to catch that Dir.pwd in the parent script to do just that
<isene>
Use case = Launch the file manager, move to directory X, move the user to directory X when she exits the file manager
<jhass>
semz: tried to dig a bit but couldn't find much. https://github.com/ruby/ruby/blob/master/doc/marshal.rdoc seems to be the main one and not too detailed, especially about what you're asking for. Maybe some can be learned from the ruby spec (github.com/ruby/spec) and the jruby implementations in addition to the CRuby implementation
Technodrome has joined #ruby
<jhass>
isene: that's where I say it's ugly, you gotta make sure your file manager only prints the directory as output, then you can just file-manager() { cd "$(actual-file-manager)" }
<jhass>
alternatives are starting to parse the output of the command in the shell function and print the path with some marker that makes it easier (error prone) or as you say write some file to /tmp (easy to pollute things, racy for concurrent invocations)
jmcgnh has joined #ruby
<jhass>
you probably also want to make use of exit codes in order to only try to cd on success
<isene>
jhass: I source the simplest of scripts: function r { cd "$(rtfm)" } - but that went south in a second - the file manager got started (I think) but the terminal just halts. I know the fm responds since when I press "q" to exit, it does in fact exit and populates the screen with lots of curses code (the rtfm is a curses application).
<jhass>
well, yeah, we're capturing the whole of stdout here
<jhass>
I guess you gotta use one of stdout and stderr for each function, display and outputting the path and only capture one and leave the other connected to the shell's
<isene>
So, we're one step closer - but we're not letting rtfm actually take over the terminal to draw on the screen
<isene>
jhass: That reads like hebrew to me
<jhass>
maybe it's possible to reopen the shell's pty for "drawing" but that's getting quite complex here
<jhass>
well read up on stdin, stdout, stderr and I/O redirection, quite fundamental concepts on UNIX systems
<isene>
sure - those are fine - what got me was "only capture one and leave the other connected to the shell's" - But - it seems to be a way... looking at how broot does it, I think I have a path now. Thanks for playing ball.
<jhass>
passes it in as an option to avoid the concurrency problems
<semz>
"(The first object has an index of 1)." aaaaaaaargh
<isene>
jhass: yes
<semz>
jhass: Thanks, I don't think I would have noticed that on my own during the trawl through CRuby.
<jhass>
semz: fwiw I hope you know what you're doing, I think the Ruby team sees the marshal format largely as something internal :)
<jhass>
I would always go for something else to transport data across programs
<semz>
The format wasn't my choice unfortunately. The stuff that generates this is pretty old and outdated already, so I think breaking changes are unlikely at least.
<semz>
Though outdated software is its own bag of worms of course
<jhass>
mh, I see. Bummer
<jhass>
I guess you evaluated the route of just having a ruby program (targeting the same ruby version as the source program) transform it into some sane transport format?
<semz>
yeah
CustosLimen has quit []
Twemlow has joined #ruby
Twemlow has quit [Client Quit]
postmodern has quit [Quit: Leaving]
TCZ has quit [Quit: Leaving]
dionysus69 has joined #ruby
Nahra has quit [Quit: leaving]
weaksauce has quit [Ping timeout: 258 seconds]
howdoi has joined #ruby
dionysus69 has quit [Ping timeout: 246 seconds]
ChmEarl has joined #ruby
burgestrand has joined #ruby
TCZ has joined #ruby
burgestrand has quit [Quit: burgestrand]
ellcs has joined #ruby
hiroaki has quit [Ping timeout: 246 seconds]
dviola has quit [Ping timeout: 265 seconds]
hiroaki has joined #ruby
markong has quit [Remote host closed the connection]