Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
Ruby equivalent of syscall.Exec in golang

I want to set environment variable programatically with ruby. In Golang we have

syscall.Exec(os.Getenv(SHELL), []string{os.Getenv(SHELL)}, updated)

This opens a new default shell with the updated variables. So the terminal where we execute the go program will have those variables persisted for the session.

I'm new to ruby not able to find the equivalent there. Please help me.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

To get/set environment variables, you could use ENV hash, then to make system calls, where you could see the standard output (not as ` that will return you the output as a string), you could call system.
The default shell should be available in ENV['SHELL'], so what you'll need should be something like:

ENV['FOO'] = '123' # FOO will last for the entire ruby session
system({'BAR' => '456'}, ENV['SHELL']) # BAR will last until system call has finished
system(ENV['SHELL']) # Here, only FOO will be available, not BAR
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!