Here’s my personal shell’s ‘head file’ tool.h
#!/bin/echo Warnning! this libiary must be scourced in file!
#ostype(): define the system type in val OSTYPE
ostype(){
osname=`uname -s`
echo $osname
}
ostype
When I call it directly like ./tool.h it prints the first line that after “#!/bin/echo”
And here is my question: How can I call this function “ostype” in ‘tool.h’ by anoter shell script file with it’s first line #!/bin/bash?
I don’t know how to import the “head file” just like import Jquery plug-in in Javascript.
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
You should not use
.has the suffix and probably should use.sh(or possibly.cshif you’re using a C shell derivative).Depending on your shell, you might use the ‘dot’ command (POSIX, Bourne, Korn, Bash) shells, or the
sourcecommand (C Shell, Bash):These both read the script (after finding it via a PATH-like search if there’s no slash in the name) as part of the current shell environment (as opposed to running it in a sub-shell). This means that changes made by the dotted script take effect in the calling shell – which is important when defining functions.