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

NAME

relpath - Return the relative pathname

VERSION

This document describes version 0.052 of relpath (from Perl distribution App-relpath), released on 2023-11-20.

SYNOPSIS

Usage:

 % relpath [OPTIONS] <filename> ...

Examples:

 % relpath /etc/passwd /home/titin/f1 subdir/f2
 ../../etc/passwd
 f1
 subdir/f2

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

 % quickabspath .  ;# gives absolute path but does not resolve symlinks
 /home/ujang/sym1

 % relpath /home/ujang/dir1
 .
 % relpath /home/ujang/sym1
 ../sym1

DESCRIPTION

This program complements the Unix command realpath. realpath converts relative pathnames to absolute ones, while relpath does the opposite.

The actual routine used is File::Spec's abs2rel() function.

By default, will check first that the filenames exist, unless --nocheck (-C) is specified.

EXIT CODES

0 on success.

1 on some error, e.g. some filenames are not found (and --check is on).

99 on command-line options error.

OPTIONS

  • --[no]check, -c

    Whether to check that file exists. Default is on.

  • -C

    Alias for --nocheck.

FAQ

HOMEPAGE

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

SOURCE

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

SEE ALSO

realpath, quickabspath

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

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, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2023, 2015, 2014 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.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-relpath

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.