[Israel.pm] changing the shell called by system()

Shlomi Fish shlomif at iglu.org.il
Fri Aug 26 04:54:19 PDT 2005

On Tuesday 23 August 2005 16:59, Offer Kaye wrote:
> Hi,
> Is there a way to change the shell called by the system() (and
> backticks) command?
> Currently sh is called, I would like to change it to tcsh.

I don't think it's possible. Reading from "perldoc -f system":

If there is
only one scalar argument, the argument is checked for shell
metacharacters, and if there are any, the entire argument is
passed to the system's command shell for parsing (this is
"/bin/sh -c" on Unix platforms, but varies on other platforms).

And from man 3 system (on Linux at least):

system()  executes a command specified in command by calling /bin/sh -c
command, and returns after the command has been completed.  During exe-
cution  of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT
will be ignored.

Possible workarounds:

1. Write your own system-like command using fork and exec(). (may not be very 

2. Use something like:

tcsh -c 'set a=Hello; echo $a'

This is a proof-of-concept script. If you want to ensure safety, you should 
probably write some glue functions to encapsulate the tcsh command with 
quoting and all.


	Shlomi Fish

Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://www.shlomifish.org/

Tcl is LISP on drugs. Using strings instead of S-expressions for closures
is Evil with one of those gigantic E's you can find at the beginning of 

More information about the Perl mailing list