All Projects → morgant → realpath

morgant / realpath

Licence: other
A portable bash implementation of `realpath`.

Programming Languages

shell
77523 projects

Labels

Projects that are alternatives of or similar to realpath

readdir
Recursively read a directory, blazing fast. Use with picomatch or micromatch to match globs.
Stars: ✭ 37 (+85%)
Mutual labels:  realpath
react-native-compressor
The lightweight library for compress image, video, and audio with an awesome experience
Stars: ✭ 157 (+685%)
Mutual labels:  realpath
realpaths
Fast, portable path manipulation and symlink resolution in 2K of pure bash
Stars: ✭ 27 (+35%)
Mutual labels:  realpath

realpath

by Morgan Aldridge [email protected]

realpath on OpenHub Build Status Donate

OVERVIEW

A portable realpath() written in bash. The realpath() function in C (and many other languages) will return the absolute path when provided a relative path, but there's not an equivalent in bash. It's often suggested to use readlink, but while common under Linux, it's not available on many other platforms, esp. BSD-based platforms such as Mac OS X.

This is a simple implementation, originally based on this solution, which uses pwd. Pass it one or more relative (or absolute, but that's somewhat pointless) file/directory paths and, if it exists, it'll output the absolute path to STDOUT. It'll also return 0 if successful or 1 if unsuccessful (also meaning the file/directory path doesn't exist). Naturally, it does not handle tildes (~) in paths as that should've been processed by the calling shell.

UNIT TESTS

Unit tests are implemented using roundup. These tests can be run by executing roundup in the 'realpath' project directory (it'll automatically find and run the realpath-test.sh tests). If you discover any failing tests on your platform or any additional edge cases that should be tested, please let me know ASAP.

LICENSE

Copyright (c) 2012, Morgan Aldridge All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].