Timeline for Unix-portable way to get script's absolute path in zsh?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 18, 2024 at 17:18 | comment | added | Jack |
This is great! Fyi to others: you can get rid of the script name itself by removing the basename part: canonical=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
|
|
| Feb 21, 2018 at 18:24 | comment | added | Ville |
On Ubuntu 16.04 with zsh, if I execute this either directly or in the subshell (as suggested) while in my home dir (/home/ville), it prints out /home/ville/zsh.
|
|
| Feb 18, 2018 at 1:26 | history | edited | Jeff Schaller♦ | CC BY-SA 3.0 |
added 1 character in body
|
| Jun 11, 2014 at 10:26 | comment | added | Stéphane Chazelas |
Where it's not equivalent to GNU's readlink -f is when the script itself is a symlink.
|
|
| May 21, 2013 at 17:18 | comment | added | Tim Kennedy | i like it! so far, that's pretty portable. works on Solaris, OmniOS, Linux, Mac, and even Cygwin on Windows 2008. | |
| May 21, 2013 at 16:25 | history | answered | user17591 | CC BY-SA 3.0 |