rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
grenierm has joined #ruby
jenrzzz has quit [Ping timeout: 255 seconds]
jenrzzz has joined #ruby
Vonter has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
gr33n7007h has quit [Quit: WeeChat 4.2.2]
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 255 seconds]
grenierm has quit [Quit: Client closed]
grenierm has joined #ruby
jenrzzz has joined #ruby
Trivial has joined #ruby
gr33n7007h has joined #ruby
Vonter has joined #ruby
gaussianblue has quit [Quit: leaving]
jenrzzz has quit [Ping timeout: 245 seconds]
gaussianblue has joined #ruby
wand has quit [Remote host closed the connection]
wand has joined #ruby
jenrzzz has joined #ruby
Vonter has quit [Read error: Connection reset by peer]
Vonter has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
Guest98 has joined #ruby
Guest98 has quit [Client Quit]
jenrzzz has joined #ruby
nmollerup has joined #ruby
jenrzzz has quit [Ping timeout: 252 seconds]
jenrzzz has joined #ruby
donofrio__ has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
grenierm has quit [Quit: Client closed]
donofrio has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
<konsolebox>
Anyone knows how to explicitly prevent ruby from interpreting arguments in a shebang when the script is called with `ruby script.rb`?
jenrzzz has joined #ruby
Trivial has quit [Ping timeout: 264 seconds]
patrick has quit [Ping timeout: 256 seconds]
patrick_ is now known as patrick
Hel67 has joined #ruby
Hel67 has quit [Client Quit]
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
donofrio has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 252 seconds]
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
jenrzzz has joined #ruby
gaussianblue has quit [Quit: leaving]
bambanxx has joined #ruby
ken_barber has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
jenrzzz has joined #ruby
<adam12>
konsolebox: Example?
<konsolebox>
adam12: I created this C program to make sure a stub only executes against the ruby implementation it was built to in Gentoo. When I add --autopick as the first token of the argument it gets read by the Ruby implementation that's loaded. Ruby apparently scans the shebang header for options.
<adam12>
Can you put `--` before it. `-- --autopick`?
<konsolebox>
adam12: For example a script that's supposed to have #!/usr/bin/ruby will be modified to have `#!/usr/bin/rubyexec --autopick,ruby32,ruby31`. So if none of the implementations are currently "selected" in Gentoo, either of those two that are available will be executed instead.
<konsolebox>
adam12: That doesn't help it. I tried it already.
<konsolebox>
adam12: What does help is placing the argument after the implementations so I'll have ruby32,ruby31,--autopick.
<konsolebox>
adam12: But I prefer explicitly telling Ruby not to do scanning instead of blindly relying on it just ignoring non-option arguments.
jenrzzz has quit [Ping timeout: 255 seconds]
<adam12>
konsolebox: I can't say I've seen it eat args like that.
<adam12>
konsolebox: rubyexec is your C program?
<konsolebox>
Yes
<adam12>
konsolebox: Can you share src?
bambanxx has joined #ruby
<mooff>
i remember reading about the feature. you can put e.g. "#!/bin/ruby -r ostruct", then don't have to require "ostruct" in the script, even if run directly with /bin/ruby
<adam12>
konsolebox: Are you passing argv back to ruby unchanged?
<konsolebox>
No it's modified through create_new_argv. I already printf'd each argument of the resulting new_argv. It's made right as expected.
<adam12>
konsolebox: Do you are stripping `--autopick,etc` from argv before execv ruby?
<adam12>
so/Do/So
mark22k has joined #ruby
<konsolebox>
adam12: Yes, argv[0] becomes path to ruby implementation binary, argv[1] becomes path to script. argv[2] becomes NULL. None else are added unless an argument is passed.
<adam12>
konsolebox: Ohh. I see. But ruby is seeing `--autopick`? If not, then I am not sure I follow :(
<konsolebox>
Yes Ruby still "sees" --autopick because it scans the shebang of the script.
<adam12>
OOh.
<konsolebox>
Not as an argument but from the script itself.
<adam12>
What if you put a second shebang
<adam12>
#!ruby
<adam12>
after the first one
<adam12>
I know it's a hack but I'm just curious.
jenrzzz has joined #ruby
<adam12>
There's also ruby -x
<konsolebox>
adam12: Doesn't help. With a script just having $'#!/usr/bin/rubyexec --autopick,ruby32,ruby31\n#!ruby\n\nputs ARGV.inspect', I get "ruby: invalid option --autopick,ruby32,ruby31 (-h will show valid options) (RuntimeError)" (ruby script.rb) or "/usr/bin/ruby32: invalid option --autopick,ruby32,ruby31 (-h will show valid options) (RuntimeError)" ($PWD/script.rb)
srbaker has quit [Quit: srbaker]
<adam12>
konsolebox: Would you humour me by calling rubyexec something else like `konsolexec`?
<konsolebox>
Lol
<konsolebox>
I name it similar to Gentoo's pythonexec
<adam12>
I know, but what if the scan looks for `/ruby.*/` (since a lot of older uses of ruby involved number suffixes like ruby19)
<mooff>
what if you tell ruby to get the script from stdin, then write it from the second line onwards to its stdin
jenrzzz has quit [Ping timeout: 256 seconds]
<konsolebox>
mooff: I think that'll make it complicated and may affect some scripts that may read the script's filename. Also redirecting the script code input to stdin would be risky since it may affect actually stdin input for it.
<konsolebox>
adam12: I currently have a modified Gentoo package of https://github.com/defunkt/gist using it. It's working for now because I placed the option at the end.
<adam12>
The C code is essentially `if (strstr(shebang, "ruby")) { parse args }`
<konsolebox>
Hmm
<mooff>
^ sounds like it. inside if (strstr(shebang, "#!"))
<konsolebox>
I might have to name it to something else then.
<mooff>
or strpos() == 0, or whatever
<mooff>
yeah.
<mooff>
execrb, rbexec?
jenrzzz has joined #ruby
<konsolebox>
I'm thinking of rbexec as one of it yes. I also thought about simply rx but then it would be a bit cryptic. Anyway I'm not in a hurry to decide. I'll take my time.
<adam12>
konsolebox: I'll be curious to know if renaming binary fixes your issue. lmk when you get a chance.
<konsolebox>
adam12: I can try it now.
<konsolebox>
Yep it fixed it.
<adam12>
Interesting stuff.
<konsolebox>
Gist ran with --autopick,ruby...
<adam12>
Learn something new every day, I guess.
<konsolebox>
adam12: Yeah, Thanks for the help :)
<adam12>
There's a re-exec trick that I think leah2 shared? which I thought was similar.
rvalue has quit [Remote host closed the connection]
zayd has quit [Remote host closed the connection]
r3m has quit [Remote host closed the connection]
c10l0 is now known as c10l
r3m has joined #ruby
dannyAAM_ is now known as dannyAAM
rvalue- is now known as rvalue
jenrzzz has joined #ruby
zayd has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
bambanxx has joined #ruby
jenrzzz has joined #ruby
<zayd>
I'm thinking of adding configuration to my fetch script by doing it with a custom .rb file that the user writes that defines the main function and what is printed instead of the traditional .conf or .yml. Is this a bad idea? I feel like it could allow for more natural and more fine-tuned customization with less moving parts.
<adam12>
zayd: Seems fine and not actually that abnormal.
<adam12>
zayd: It's likely audience dependent. If you think they can write Ruby then it would probably be more flexible. If they can't write Ruby, then yaml/whatever better solution.
<zayd>
Yeah, I was playing with Suckless' stuff recently in a virtual machine and was kind of inspired by how they do their configs. I figured that this would probably be even easier because you don't have to recompile and the different configs can be stored in their own files in $XDG_CONFIG_HOME and then selected from a command line option like `--config /path/to/config.rb`
<zayd>
adam12: I feel like Ruby is easy enough to approach for this type of thing and even if a user doesn't want to do that, they can either use the default config or use the 3000 other and probably better fetch scripts that come out daily
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
nopc0de has quit [Read error: Connection reset by peer]