I am looking for a simple solution to get the absolute path of the current script. It should be platform independent (I want it to work on linux, freebsd, macos and without bash).
EDIT: Solution for retrieving the repository path script:
DIR = "$ (cd" $ (dirname "$ 0") "& pwd)" (source: Getting the source Bash script directory from the inside )
For zsh, FWIW scripts:
#! /bin/zsh - fullpath=$0:A
#!/bin/sh self=$( self=${0} while [ -L "${self}" ] do cd "${self%/*}" self=$(readlink "${self}") done cd "${self%/*}" echo "$(pwd -P)/${self##*/}" ) echo ${self}
" ". pwd -P POSIX, . readlink , POSIX.
pwd -P
readlink
, . - , realpath .