The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

realpath - Print the resolved (absolute) path

VERSION

This document describes version 0.003 of realpath (from Perl distribution App-realpath), released on 2021-07-16.

SYNOPSIS

 % realpath [OPTION]... <FILE>...
 % abspath  [OPTION]... <FILE>...

To demonstrate how realpath, quickabspath, and relpath give you different results:

 % pwd
 /home/ujang

 % mkdir dir1
 % ln -s dir1 sym1

 % cd sym1

 % realpath .      ;# gives absolute path and resolve symlinks
 /home/ujang/dir1
 % abspath .       ;# an alias for realpath
 /home/ujang/dir1
 % realpath foo    ;# uses PWD for working directory
 /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

DESCRIPTION

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.

When -L (--logical) option is given, will use PWD environment variable and not resolve symlinks.

EXIT CODES

0 on success.

99 on command-line options error.

OPTIONS

--physical, -P

--logical, -L

FAQ

ENVIRONMENT

PWD

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-realpath.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-realpath.

BUGS

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.

SEE ALSO

Unix utility realpath

relpath, quickabspath

Cwd

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2019 by 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.