FAQ
This and other RFCs are available on the web at
http://dev.perl.org/rfc/

=head1 TITLE

Request For New Pragma: Shell

=head1 VERSION

Maintainer: Bryan C. Warnock <bwarnock@gtemail.net>
Date: 5 Aug 2000
Version: 1
Mailing List: perl6-language@perl.org
Number: 42

=head1 ABSTRACT

Perl 6 should add a new pragma called C<shell>.

=head1 DESCRIPTION

The shell that Perl uses for shell interpretation is defined at
compile time. Furthermore, it is optimized away when no metacharacters
are found within the command string.

There are times when one may need (or desire) to change the shell used
for interpretation, as well as force shell interpretation, regardless
of optimization, for consitency's sake.

Perl runs on many platforms. Many of these platforms, either by default,
desire, or need, may have multiple command interpreters that Perl may want
to interface with by default. (ie, through the use of backticks or system().)

Perl is not just a glue language, but a SuperGlue language. I ab^H^Huse
Perl to interact with a lot of home-grown command interpreters as either
a driver, a hardware controller, or Expect-type engine. It's a lot more
DWIMmer when I can operate in that environment, vice the standard OS one.

Furthermore, there are times when speed be damned! I need every `` to go
through the command interpreter in order to get back consistent results,
and I don't want to have to mangle the output string in order to force
a metacharacter.

It is important, however, that this be lexically scoped. One can't really
afford to have some unknown module expect /bin/sh and accidentally send
the command to turn on a robot's "Kill Human" mode.

=head1 MOTIVATORS

Laziness, and perhaps a bit of Hubris.

=head1 IMPLEMENTATION

This was an easy hack in Perl 5, except for the scoping issue. Ideally,
there'd be a -force flag to check, and a method to change the location
of the shell, the shell arguments, and perhaps what is defined as a shell
metacharacter.

=head2 SUMMARY OF IMPLEMENTATION

See above. I hacked this for Perl 5 in about two minutes, minus the scoping,
which I never could figure out. :-(

=head2 IMPACT

=over 4

=item *

Impact on Perl 5. Mutual compatibility between Perl 5 and Perl 6, with the
exception of C<use shell> and the semantics it would add. (Obviously,
other changes to the language notwithstanding.)

=back

=head2 UNKNOWNS

=over 4

=item *

What if the interfaced modules returns things that `` and system() don't
expect?

=back

=head1 REFERENCES

Upcoming RFC on module scoping.

Search Discussions

  • Skud at Aug 6, 2000 at 4:25 am

    On Sat, Aug 05, 2000 at 09:14:49PM -0000, Perl6 RFC Librarian wrote:
    =head1 TITLE

    Request For New Pragma: Shell
    Pragmas have lower case names by convention, so this should be "use
    shell".

    K.

    --
    Kirrily Robert -- <skud@netizen.com.au> -- http://netizen.com.au/
    Open Source development, consulting and solutions
    Level 10, 500 Collins St, Melbourne VIC 3000
    Phone: +61 3 9614 0949 Fax: +61 3 9614 0948 Mobile: +61 410 664 994
  • Bryan C . Warnock at Aug 6, 2000 at 1:01 pm

    On Sun, 06 Aug 2000, skud@netizen.com.au wrote:
    On Sat, Aug 05, 2000 at 09:14:49PM -0000, Perl6 RFC Librarian wrote:
    =head1 TITLE

    Request For New Pragma: Shell
    Pragmas have lower case names by convention, so this should be "use
    shell".
    Yes, it's lc 'shell' everywhere but the title. It's that damned
    disconnect between English and...., English.



    --
    Bryan C. Warnock
    (bwarnock@gtemail.net)
  • Johan Vromans at Aug 6, 2000 at 5:02 pm

    Perl6 RFC Librarian writes:

    There are times when one may need (or desire) to change the shell used
    for interpretation, as well as force shell interpretation, regardless
    of optimization, for consitency's sake.
    print `fancysh -c 'your uninterpreted and unoptiomized shell command'`;

    Or am I overlooking something?

    -- Johan
  • Bryan C . Warnock at Aug 6, 2000 at 10:33 pm

    On Sun, 06 Aug 2000, Johan Vromans wrote:
    Perl6 RFC Librarian <perl6-rfc@perl.org> writes:
    There are times when one may need (or desire) to change the shell used
    for interpretation, as well as force shell interpretation, regardless
    of optimization, for consitency's sake.
    print `fancysh -c 'your uninterpreted and unoptiomized shell command'`;

    Or am I overlooking something?
    Well, for me, the lazyness factor. :-)

    There is the potential (for someone, I'm sure, as I haven't yet) to
    want to run all system commands through an alternate command
    interpreter - including the ones you didn't write. Me, I just want to
    run most of them in a couple of applications.

    @results = shell_me($shell_command);
    # With the appropriate sub backing it up

    is, to me, the entire point behind the backticks.

    @results = `$shell_command`;

    It's intuitive, quick, and DWIM.

    Surely, Perl on Windows doesn't require /bin/sh, does it?

    --
    Bryan C. Warnock
    (bwarnock@gtemail.net)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl6-language @
categoriesperl
postedAug 5, '00 at 9:14p
activeAug 6, '00 at 10:33p
posts5
users4
websiteperl6.org

People

Translate

site design / logo © 2021 Grokbase