To answer the question: "${0}" should be the CURRENT shell name. You could try to get the version information as well (might be limited and I haven't tried that but you should be able to get this from the environment variables).
The calling process is your parent. You should never check your parent's property. If you need - then most probably the application needs an re-design.
My guess is that the parent process should call this code with a pre-formatted text like "{bold}this{red}is{normal}some text". Of course we should ask ourselves whether it is a good idea to use shell scripts here (probably you should use python/perl/some high level language).
To correct your approach: If you call a script then its executable should be specified in the first line (ex. #!/bin/ksh). If you have several scripts and every is written for a different shell - you should execute them and this would execute a new shell/whatever instance. Since every shell seems to be a separate entity (as it seems from your description) - you should either normalize them (re-write everything to the same script/shell/whatever) or just leave them as it is right now without using any common shell script file. There is nothing worse than using thousands of different languages in a single project maintained by thousands of developers.
If your script is called from other scripts (using several different shells to execute them) - then I cannot understand how this is a library script. Maybe this is a script that is executed with some options specified?
By the way: My English is not the the best but bellow you can find somewhat corrected version of your post (maybe someone else can correct it more? or even correct my post?). Sorry for being the fussy kind:
Quote:
Hello,
I have a lib file which contains a function that gets (receive would be better) text to print on to the screen /by/ using echo command.
Several scripts are inculded in this lib and /use/ are using this function.
Each one of them is written in a different shell language (sh ksh & bash).
This is causing some issues when using backslash character as part of the test that /sends to this function/ (Sorry, but I do not understand that part).
I would like to create two echo commands which /will/ would be executed according to the current shell.
How can I extarct the current shell which is used by the calling script /to the print function / to print the text output?
Thanks /a head/ in advance
Alalush