{"id":22367692,"url":"https://github.com/hugojosefson/realpath-compat","last_synced_at":"2026-04-11T18:03:16.175Z","repository":{"id":66830251,"uuid":"532808922","full_name":"hugojosefson/realpath-compat","owner":"hugojosefson","description":"An implementation of realpath(1) that should work everywhere.","archived":false,"fork":false,"pushed_at":"2022-09-05T08:43:51.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-31T17:48:15.859Z","etag":null,"topics":["bash","ksh","linux","mac","macos","portable","readlink","readlink-f","realpath","sh","shell","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hugojosefson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-05T08:24:57.000Z","updated_at":"2022-09-05T08:35:38.000Z","dependencies_parsed_at":"2023-02-23T01:30:40.931Z","dependency_job_id":null,"html_url":"https://github.com/hugojosefson/realpath-compat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugojosefson%2Frealpath-compat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugojosefson%2Frealpath-compat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugojosefson%2Frealpath-compat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugojosefson%2Frealpath-compat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hugojosefson","download_url":"https://codeload.github.com/hugojosefson/realpath-compat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245689481,"owners_count":20656416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","ksh","linux","mac","macos","portable","readlink","readlink-f","realpath","sh","shell","zsh"],"created_at":"2024-12-04T18:20:18.425Z","updated_at":"2026-04-11T18:03:16.109Z","avatar_url":"https://github.com/hugojosefson.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# realpath-compat\n\nAn implementation of [realpath(1)](https://linux.die.net/man/1/realpath) that\nshould work everywhere.\n\n## Installation\n\nCopy this function into your shell script:\n\n```sh\nrealpath_compat(){ if [ $# -eq 0 ];then echo \"Usage: realpath_compat FILE [FILE ...]\"\u003e\u00262;return 1;fi;while [ $# -gt 0 ];do file=\"$1\";shift;if ! [ -e \"$file\" ];then echo \"realpath_compat: $file: No such file or directory\"\u003e\u00262;return 1;fi;realpath \"$file\" 2\u003e/dev/null||readlink -f \"$file\" 2\u003e/dev/null||zsh -c 'echo ${0:A}' \"$file\" 2\u003e/dev/null||python3 -c \"import os; import sys; print(os.path.realpath(sys.argv[1]))\" \"$file\" 2\u003e/dev/null||node -e \"console.log(require('fs').realpathSync(process.argv[1]))\" \"$file\" 2\u003e/dev/null||echo \"realpath_compat: $file: Could not resolve real path\"\u003e\u00262;done;}\n```\n\nAlternatively, copy the non-minified version found in\n[realpath-compat](realpath-compat#L6-L30).\n\n## Usage\n\nCall the function, with some file(s) as argument(s).\n\nExample:\n\n```sh\n#!/bin/sh\nset -e\n\nrealpath_compat(){ if [ $# -eq 0 ];then echo \"Usage: realpath_compat FILE [FILE ...]\"\u003e\u00262;return 1;fi;while [ $# -gt 0 ];do file=\"$1\";shift;if ! [ -e \"$file\" ];then echo \"realpath_compat: $file: No such file or directory\"\u003e\u00262;return 1;fi;realpath \"$file\" 2\u003e/dev/null||readlink -f \"$file\" 2\u003e/dev/null||zsh -c 'echo ${0:A}' \"$file\" 2\u003e/dev/null||python3 -c \"import os; import sys; print(os.path.realpath(sys.argv[1]))\" \"$file\" 2\u003e/dev/null||node -e \"console.log(require('fs').realpathSync(process.argv[1]))\" \"$file\" 2\u003e/dev/null||echo \"realpath_compat: $file: Could not resolve real path\"\u003e\u00262;done;}\n\nmy_real_path=\"$(realpath_compat \"$0\")\"\necho \"This script's real path is: ${my_real_path}, and that's true even if you call it via a symlink.\"\n```\n\n## License\n\n\u003cp xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dct=\"http://purl.org/dc/terms/\"\u003e\u003ca property=\"dct:title\" rel=\"cc:attributionURL\" href=\"https://github.com/hugojosefson/realpath-compat\"\u003erealpath-compat\u003c/a\u003e by \u003ca rel=\"cc:attributionURL dct:creator\" property=\"cc:attributionName\" href=\"https://www.hugojosefson.com/\"\u003eHugo Josefson\u003c/a\u003e is marked with \u003ca href=\"http://creativecommons.org/publicdomain/zero/1.0?ref=chooser-v1\" target=\"_blank\" rel=\"license noopener noreferrer\" style=\"display:inline-block;\"\u003eCC0 1.0\u003cimg style=\"height:22px!important;margin-left:3px;vertical-align:text-bottom;\" src=\"https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1\"\u003e\u003cimg style=\"height:22px!important;margin-left:3px;vertical-align:text-bottom;\" src=\"https://mirrors.creativecommons.org/presskit/icons/zero.svg?ref=chooser-v1\"\u003e\u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugojosefson%2Frealpath-compat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugojosefson%2Frealpath-compat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugojosefson%2Frealpath-compat/lists"}