<[0x1eef]>
Oh woops. No splat. Process.spawn "/bin/sh", "-c", argv.join(" ").
<HappyPassover>
ruby doobie doo
jenrzzz has quit [Ping timeout: 252 seconds]
<zayd>
[0x1eef]: that works after correcting argv to ARGV
<zayd>
thanks
<zayd>
how would i get the output of the actual command instead of the pid though? i don't see anything on the ruby docs pages for it
<HappyPassover>
some script or code example?
jenrzzz has joined #ruby
<zayd>
HappyPassover: https://bpa.st/4HPA basically i'm trying to create something along the lines of this, it keeps giving me the pid of the process it spawns though
<HappyPassover>
that is seriously conveluted
<HappyPassover>
think differently, various tools, and simpler.
<zayd>
HappyPassover: i'm trying to reimplement neofetch in ruby, currently that part is just temporary, i'm going to switch it out for a command more efficient once i get it to actually print output
<zayd>
i just copied the line from neofetch to test things before i write the actual command
<HappyPassover>
like I said, look at other tools, many more in the CLI software tools realm.
<vms14>
you're actually writing a shell script
<HappyPassover>
I'm just trying to digest what youa re doing.
<vms14>
the whole thing would be cleaner in sh
<zayd>
HappyPassover: yeah i'll try to rewrite it to be more simple just give me a second
<HappyPassover>
read the book software tools, it will save you decades in your life.
<vms14>
and the way you're doing is not using ruby at all
<HappyPassover>
<-- best advice ever.
<vms14>
it's just a weird sh script
<zayd>
vms14: the rest of it is in ruby, it's just that i have to do pci stuff in sh since there doesn't seem to be one file for that that i can parse
<zayd>
is there any pci library for ruby that would make things easier?
<HappyPassover>
check out ##obscurity-rules for more advice.
<vms14>
i would recommend to put your ruby script on that chain
<vms14>
and just read from stdin or whatever
jenrzzz has quit [Ping timeout: 260 seconds]
<vms14>
also ruby has backticks like in perl
<vms14>
those will return the output of the program
<vms14>
which is what you want
<HappyPassover>
like in shell
<vms14>
btw i like to see awk on your chain
<zayd>
vms14: i was using backticks before but it seems to run into issues if you run with your user's shell as fish
<HappyPassover>
its not unique, and a leftover for various reasons, where pipe may not have been available.
<HappyPassover>
we are talking decades ago
<HappyPassover>
but they are obscure, and not needed for most reasons.
<vms14>
seems you need open3
<HappyPassover>
again, think in 'software tools', not some other paradigm.
<HappyPassover>
if you do not, you get spaghetti code quickly.
<vms14>
i keep thinking it should be a shell script instead
<zayd>
i have a majority of the thing in native ruby already, so i don't see a reason to write it in sh. i just don't see a good way to do this part of it in native ruby, so i'm running a shell command for it
jenrzzz has joined #ruby
<vms14>
just use capture
<vms14>
stdout_str, status = Open3.capture2([env,] cmd... [, opts])
<zayd>
this can also probably be done by just using `lspci`.match(/something/), no?
jenrzzz has quit [Ping timeout: 255 seconds]
<vms14>
that's why i told you were writing a shell script
<vms14>
still, it might make sense to filter the output from sh
<vms14>
and the way to get rid of that sh command would be to check the files that command checks in order to give you the info
<HappyPassover>
the way to get rid of needing cli or tools at the level of shell is to simply do it right (tm)
<zayd>
vms14: i was told in #linux that it would require quite a bit of work figuring out how to deal with the files in /sys/bus/pci and all that
<vms14>
seems to use libpci
<vms14>
yeah, sorry
<vms14>
i thought you might be able to find the info on procfs
<zayd>
there appears to be a few gems on github for pci stuff but they all are 8+ years old
<vms14>
i would try to not require any gem for a script like that
<vms14>
yet, they might make everything much better
<vms14>
executing commans will always feel wrong
<vms14>
commands*
<zayd>
i'm only requiring friendly_numbers and optparse so far, i would like to not add anything else besides a config parser but if it makes things a lot easier it is what it is
<vms14>
but they add a dependency
<vms14>
well i'd say it's wise to not care about that
<vms14>
and actually use what you have available
<vms14>
if there's a gem that already exists and does what you need, logic says you should use it
<zayd>
yeah true, i would add for that, i just don't want to add like 3 million gems when i could already do that stuff with what comes in ruby. that isn't the case for the lspci stuff though, so if i can find a gem that makes things easier for that i would use it
jenrzzz has joined #ruby
<vms14>
that said, if i were you i would just use the command xD
<weaksauce>
zayd use open3 and instead of awk just use ruby's robust handling
donofrio_ has joined #ruby
<zayd>
i don't really see a point in using awk either tbh, i was only copying that in as a test
<zayd>
i'll try out open3 i guess
<vms14>
hahaha
<weaksauce>
> On a Unix-like system, the shell invoked is /bin/sh; otherwise the shell invoked is determined by environment variable ENV['RUBYSHELL'], if defined, or ENV['COMSPEC'] otherwise.
<weaksauce>
open3 ^
donofrio has quit [Ping timeout: 245 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
<weaksauce>
technically that is the docs for Process