Which shell does a Perl system() call use?

If you don't want to invoke a shell, call system with a list:

system 'mycommand', 'arg1', '...';
system qw{mycommand arg1 ...};

If you want a specific shell, call it explicitly:

system "/path/to/mysh -c 'mycommand arg1 ...'";

It's complicated. Perl does not necessarily invoke a shell. Perldoc says:

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). If there are no shell metacharacters in the argument, it is split into words and passed directly to execvp , which is more efficient.

So it actually looks like you would have the arguments passed right to execvp. Furthermore, whether the shell loaded your .bashrc, .profile, or .bash_profile depends on whether the shell is interactive. Likely it isn't, but you can check like this.

Tags:

Shell

Perl

System