in reply to Re: RFC: UNIX shell to Perl converter
in thread RFC: UNIX shell to Perl converter

With respect, the shell can do quite a lot. Korn shell and Bash are more than just program launchers, Bash 3, for example, supports Extended REs. Whole applications are written in Korn, however mis-guided that might be.
I agree that converting a shell script that just called external programs to a perl script that called the same external programs would be a waste of time, but I hope to replace utility programs with Perl equivalents.
  • Comment on Re^2: RFC: UNIX shell to Perl converter

Replies are listed 'Best First'.
Re^3: RFC: UNIX shell to Perl converter
by merlyn (Sage) on Oct 09, 2006 at 17:46 UTC
    No, you can't really eliminate any forks, because you don't know who needs to know $? at the right time, or depends on a certain number of kids being present.

    It's like any translation problem... there's the surface syntax, which might appear relatively easy to translate, but then there's the deep semantics: all the side effects of the steps. So you either have to emulate the deep semantics precisely, or you have to analyze and understand enough of the rest of the program to know what you can avoid emulating. Ugh, on either side.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Indeed. $? is set by just about any command in the shell (I'm not talking csh here), including [, [[, and ((, so it can affect the entire script, not just forks. Handling this is central to the task.