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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello fellow monks,

Quick description: in bash, you can write functions to help with larger scripts, and these are stored in the bash environment somehow (ie they can persist between scripts if "source" is used). How do I set up those functions in the environment from Perl?

Long version: I'm trying to create a stop-gap perl script for automating the build process at the company I work for. The existing build script is done in a pair of bash shell scripts, called from cygwin under windows. I'm running Perl 5.8.0 (Win32 installer version).

The existing build scripts use a two step approach. The first script is designed to be used as a .bash_profile script, or "source"'d in order to import the environment variable definitions into the shell environment. It also defines a few (*cough* evil *cough*) bash script functions that then become available to subsequent scripts called in the same shell.

The second script is the top level script that traverses the source directory tree and builds each of the modules in turn. It extensively uses the bash functions defined by the first script. I'd rather not rework every lower level build script just now (at least until I can rewrite the whole sorry mess).

The big problem is that in order to invoke a shell script, I have to call the interpreter directly. As two separate scripts, this means that they are executed in separate subshells, meaning the environment variables defined in the first script don't carry over.

I can replicate the environment variables using perls $ENV{} facility, but is it possible to use that same interface to add bash function definitions to the environment as well? This would allow me to dispense with the first script entirely, and just call the actual build script.

Many thanks in advance for any perl wisdom provided!
Mike


In reply to Creating bash functions using perls $ENV interface by tid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-25 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found