This snippet detects various information about the shell script in which it is being executed. Copy and paste it into the top of your script.
Variables set are as follows:
$__SHELL:bashorzsh$__SOURCED:trueif the file was invoked usingsource filenameor. filename, otherwise it will be blank.$__SCRIPT_PATH: the full absolute path to the script.$__SCRIPT_DIR: the full absolute path to the script's directory.$__SCRIPT_PATH_DEREFERENCED: the full absolute path to the script, dereferencing all symbolic links.$__SCRIPT_DIR_DEREFERENCED: the full absolute path to the script's directory, dereferencing all symbolic links.
If you change those
echostatements toprintf %s "$1"then you can remove the calls to.strip()considering that they could erroneously remove legitimate whitespace.