changing the shell used by 'system' 
Author Message
 changing the shell used by 'system'

Is it possible to determine what shell Ruby is going to use for spawned
commands?

As matz notes in
  http://www.*-*-*.com/
none of the env vars SHELL, RUBYSHELL, COMSPEC are used.

--
Joel VanderWerf                          California PATH, UC Berkeley

http://www.*-*-*.com/                       FAX (510) 231-9512



Sat, 01 May 2004 18:40:21 GMT  
 changing the shell used by 'system'

Quote:

> Is it possible to determine what shell Ruby is going to use for spawned
> commands?

Ruby tries to do the best it can to determine whether it is possible to do
a simple fork+exec of the process, and if it can, then it will.  That is,
if you do:

  system("rm -f foo")

then Ruby will call fork() and it will then exec() /bin/rm.  However, if
you do:

  system("ls > foo")

then Ruby will call fork() and it will then exec() sh -c "ls > foo",
because of the special character '>'.  This, of course, appears to be
completely system-dependant, so I don't recommend depending on its
behavior if you can avoid it.  A much better solution would be to use
Kernel#fork and Kernel#exec yourself, or to use IO#popen.

Paul



Sat, 01 May 2004 23:43:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. using 'system' under win2000/nt/9x

2. copy , using 'system'

3. windows-cmd shell doesn't reflect _winreg changes

4. Python equivalent of shell's '$?'

5. defunct shell process using expect's spawn and close

6. Scheme Shell: Shell Scripting for the 90's

7. Scheme Shell: Shell Scripting for the 90's

8. Scheme Shell: Shell Scripting for the 90's

9. Scheme Shell: Shell Scripting for the 90's

10. Scheme Shell: Shell Scripting for the 90's

11. Can't change directory when using Netware Client

12. Using Python to change Directory ACL's in NT

 

 
Powered by phpBB® Forum Software