abspath - Print the resolved (absolute) path
This document describes version 0.004 of abspath (from Perl distribution App-realpath), released on 2021-11-26.
% realpath [OPTION]... <FILE>... % abspath [OPTION]... <FILE>...
To demonstrate how realpath, quickabspath, and relpath give you different results:
realpath
quickabspath
relpath
% pwd /home/ujang % mkdir dir1 % ln -s dir1 sym1 % cd sym1 % realpath . ;# gives absolute path and resolve symlinks (-P, the default) /home/ujang/dir1 % realpath -P . ;# ditto (-P is the default) /home/ujang/dir1 % abspath . ;# an alias for realpath /home/ujang/dir1 % realpath -L foo ;# uses PWD for working directory (-L) /home/ujang/sym1/foo % quickabspath . ;# gives absolute path but does not resolve symlinks /home/ujang/sym1 # relpath does the opposite, converting to relative path % relpath /home/ujang/dir1 . % relpath /home/ujang/sym1 ../sym1
This is the Perl-based implementation alternative for the Unix utility realpath (also aliased to abspath). It uses Cwd's realpath (which is the same as abs_path) function. The function works by reading "." (the current directory) and moving upwards until it reaches the root directory, resolving symlinks along the way.
abs_path
When -L (--logical) option is given, will use PWD environment variable and not resolve symlinks.
--logical
0 on success.
99 on command-line options error.
Please visit the project's homepage at https://metacpan.org/release/App-realpath.
Source repository is at https://github.com/perlancar/perl-App-realpath.
Unix utility realpath
relpath, quickabspath
Cwd
perlancar <perlancar@cpan.org>
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required beyond that are considered a bug and can be reported to me.
This software is copyright (c) 2021, 2019 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-realpath
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
To install App::realpath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::realpath
CPAN shell
perl -MCPAN -e shell install App::realpath
For more information on module installation, please visit the detailed CPAN module installation guide.