Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Creating bash functions using perls $ENV interface

by sgifford (Prior)
on Oct 29, 2003 at 03:15 UTC ( [id://302900]=note: print w/replies, xml ) Need Help??


in reply to Creating bash functions using perls $ENV interface

Update:Turns out you can do this. See sauoq's reply above. Sorry for the bad info!

I don't think functions are inherited across bash shells like you think they are.

For example, if I type set, I can see a function rs defined in my current shell. If I run /bin/bash --norc from this shell, I no longer see the rs function.

I think that each time bash starts up, it reads the appropriate rc files and re-defines the functions. If that's the case, you could use the BASH_ENV environment variable (see bash(1)) to point to a script containing all of the function definitions.

Another thing worth noting, although it may not be useful in your case: The easiest way to pass information like function definitions back to the shell from Perl is to print the definitions to stdout, then run something like eval `perl script.pl` in the shell.

  • Comment on Re: Creating bash functions using perls $ENV interface

Replies are listed 'Best First'.
Re: Re: Creating bash functions using perls $ENV interface
by sauoq (Abbot) on Oct 29, 2003 at 03:25 UTC
    Another thing worth noting, although it may not be useful in your case

    I'm guess it isn't useful in this case. If I read it correctly, he wants to make functions available to his subprocesses (which is doable) rather than trying to make something available to his parent process (which is not doable without jumping through hoops like this one.)

    -sauoq
    "My two cents aren't worth a dime.";
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found