Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: how does qx select a "/bin/sh equivalent"?

by ikegami (Patriarch)
on Jun 10, 2008 at 16:20 UTC ( #691265=note: print w/replies, xml ) Need Help??

in reply to how does qx select a "/bin/sh equivalent"?

To see what Perl uses,

$ perl -le'use Config; print $Config{sh}' /bin/sh

But note that on many systems, /bin/sh is bash.

$ /bin/sh -c 'echo $SHELL' /bin/bash

If you want to use an alternate shell,

sub backticks_mysh { open(my $pipe, '-|', '/bin/mysh', '-c', $_[0]) or return; local $/ = wantarray ? $/ : undef; <$pipe> }

Replies are listed 'Best First'.
Re^2: how does qx select a "/bin/sh equivalent"?
by gnujsa (Acolyte) on Jul 30, 2012 at 00:40 UTC

    Ok, it was some time ago, but I do not think that the $SHELL variable is reliable. look at my

    $ /bin/sh -c 'echo $SHELL' /bin/bash
    $ file /bin/sh /bin/sh: symbolic link to `dash'
    $ file /bin/dash /bin/dash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), d +ynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[s +ha1]=0x890a514bd261794a6d39da58ea2372fdf48e98d6, stripped
    I don't really know why. Maybe DASH keeps the environment of the calling shell, but I do not trust $SHELL.
      I used $SHELL to demonstrate that /bin/sh is not always the bourne shell. I don't see how your reply relates.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://691265]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2023-02-05 20:36 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (32 votes). Check out past polls.