bash trickery using --init-file -
I have a bash-script (let's call it / usr / bin / bosh
) After that-bang line:
#! / Bin / bash --init-file
It defines two functions, and generally interactive in an environment where the user can control a bunch of that stuff that I love. It works very well now for the interesting part, I want to be able to use in-middle-level to write new scripts clearly, without users havnig for this script. Is this possible?
I tried to write a script (let's call it / usr / bin / foo
and use it-bang line
#
which I thought would be written again to execute the command
/ usr / bin / bosh / Usr / bin / foo
which will result in the change
but it does not work, / usr / bin / foo
is executed, but / usr / bin / bosh
before
How can I make the init file a source even though the script is not interactive? Or will it have to write a cover script for this? I thought of having a script like this
#! / Bin / bash / usr / bin / bosh "$ 1"
but it will not change in an interactive shell if I run a script Does not specify, which is a shame.
Edit
Explanation So, what exactly am I asking, how can I create a file from Bamboo source (like --init-file) whether it is interactive (before starting the interactive part) or not (before executing the script)? If there is no way, is there any other way to solve my problem?
Program specified by #! There may not be another script, I'm afraid of at least Linux kernel 2.6.27.9, which gives this feature. If you run a string on Fu, you will see that you will get an ENOEXEC or exec format error, because Bob can not be executed as a standalone program.
What's happening is that executed instead of / bin / bosh and Foo is being handed in the form of input, your login shell only to silently execute Foo in a sub-shell That is the reason why it almost works.
A wrapper or a program that launches Bash, the way you want it is probably your only choice, even with an upgrade in your kernel, the way you want it, She will not work a lot.
Whatever you ever wanted to know about #! Here:
Edit: If your kernel actually supports chromatic scripts, then a work-around for / usr / bin / bosh
can be something like this:
#! / Bin / bash if [! $ PS1]; So exec / bin / bash --init-file "$ 0" -i "$ @" file ... the rest of the boss init file ...
A exec is inevitable Find the way you want it to work for it.
Comments
Post a Comment