READLINKP(1) General Commands Manual READLINKP(1)

readlinkp - return link resolved $0 + _ path. posix & portable.

readlinkp [-hHVQf] target_path
 

#!/bin/sh
full=`readlinkp "$0"`
echo "${full%?}"
~$ sh mysrc.sh #>> /home/abc/mysrc.sh ~$ mysrc (link) #>> /home/abc/mysrc.sh

-hHV
usage, version
-f
this option is ignored. this command always resolves links.
-Q
output corecode

readlinkp is mimic of `readlink -f`, but this command always add `_` to the return path end.
 
skip symbolic link resolve if the path isnt exist.

suc/fail == 0/not0

this command doesnt work if `file -h` command output is quoted

posix-shell

Copyright (C) 2021 Momi-g
 
License GPLv3+ <https://gnu.org/licenses/gpl.html>

2021-09-11 v2.0.0

readlink(1)