aboutsummaryrefslogtreecommitdiffhomepage
path: root/share
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-04-13 17:14:50 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-04-29 21:30:26 -0700
commit52731c480c789ae34e7e9bd2233b0440fab328b8 (patch)
treeebc8479dc8d3769f73f38bd400f619e2499b2b25 /share
parentf44ef3ad3f713bfbd777fdb1822f1296f6218c35 (diff)
provide a realpath implementation
Not all distros have a `realpath` command. Provide a function that uses the real command if available else use the fish builtin. Fixes #2932 (cherry picked from commit 6c329e8a839c1b5eeaf2e545b4f4084c3a8830f7)
Diffstat (limited to 'share')
-rw-r--r--share/functions/realpath.fish13
1 files changed, 13 insertions, 0 deletions
diff --git a/share/functions/realpath.fish b/share/functions/realpath.fish
new file mode 100644
index 00000000..3d33ae0f
--- /dev/null
+++ b/share/functions/realpath.fish
@@ -0,0 +1,13 @@
+# Provide a minimalist realpath implementation to help deal with platforms that may not provide it
+# as a command. If a realpath command is available simply pass all arguments thru to it. If not
+# fallback to alternative solutions.
+
+# The following is slightly subtle. The first time `realpath` is invoked this script will be read.
+# If we see that there is an external command by that name we just return. That will cause fish to
+# run the external command. On the other hand, if an external command isn't found we define a
+# function that will provide fallback behavior.
+if not type -q -P realpath
+ function realpath --description 'fallback realpath implementation'
+ builtin fish_realpath $argv[-1]
+ end
+end