In Perl, you can make "exec", "system" and "qx" use a shell other than / bin / sh (without using a construct like "exec" $ SHELL -c ... "', and without recompiling perl)?
EDIT: The motivation for this question is a bash script that runs 'export -f foo' and then uses perl in a subshell to invoke a function directly through 'system' foo. ”I'm not sure if this technique will work with all sh, and although "system" / bin / bash -c foo "may work in this scenario, I would not expect the exported function to propagate through all the / bin / sh variants. But basically, I was just curious, and now I'm interested in learning how to expand the solution to qx. Also, since I know nothing about platforms other than unix, I would like to avoid hard-coding the path to an alternative shell in the solution.
exec system. . perldoc perlsub, , ( , )
exec
system
perldoc perlsub
#!/usr/bin/perl use strict; use warnings; use subs qw/system/; sub system { #handle one arg version: if (@_ == 1) { return CORE::system "$ENV{SHELL} -c $_[0]"; } #handle the multi argument version return CORE::system @_; } print "normal system:\n"; system "perl", "-e", q{system q/ps -ef | grep $$/}; print "overloaded system:\n"; system 'ps -ef | grep $$';
exec system (, , /bin/sh , UNIX), . ( perlfunc)
/bin/sh
perlfunc
IPC::Run3 system
IPC::Run3
"exec" $SHELL -c... "? , exec , . , .:)
sub my_exec { exec $ENV{SHELL}, '-c', @_; }
, , - $ENV {SHELL}, script, . , , /etc/shells - . , , , , , .
exec /bin/sh
. .
, , .
Source: https://habr.com/ru/post/1714718/More articles:MultiThreading WebBrowser Control C # STA - multithreadingWhy is the asp.NET profile designed in such a terrible way? - c #How to create a buffer similar to * compilation * in Emacs? - emacsHow to get cell height using Prawn & Prawnto? - ruby-on-railsApache does not see subdirectories / var / www - apache2jQuery tablesorter sorting doesn't work - jqueryGet a click event on a menu element with subitems (C #) - c #Is there a way to flush the DNS cache or force a host name in Adobe AIR / Flash? - javascriptmysql: multiple join problem - joinGORM refresh () method does not get the latest data from the database - grailsAll Articles