https://github.com/JuliaLang/julia
Revision d6e1e86bccf11924c7a495db958a666bac3c11b2 authored by Rory Finnegan on 27 July 2017, 14:50:56 UTC, committed by Curtis Vogt on 27 July 2017, 14:50:56 UTC
* Added kwargs to invokelatest.

* Cleaned up invokelatest tests.

* Replaced the `eval` with a module to help with readability.
* Added a test case to demonstrate the failure condition that invokelatest fixes.

* Moved `f` and `args` inside closure rather than passing them in.
1 parent 29c78b7
Raw File
Tip revision: d6e1e86bccf11924c7a495db958a666bac3c11b2 authored by Rory Finnegan on 27 July 2017, 14:50:56 UTC
Added kwargs to invokelatest. (#22646)
Tip revision: d6e1e86
relative_path.sh
#!/bin/sh
# This file is a part of Julia. License is MIT: https://julialang.org/license

# both $1 and $2 are absolute paths beginning with /
# returns relative path to $2/$target from $1/$source

relpath () {
    [ $# -ge 1 ] && [ $# -le 2 ] || return 1
    current="${2:+"$1"}"
    target="${2:-"$1"}"
    [ "$target" != . ] || target=/
    target="/${target##/}"
    [ "$current" != . ] || current=/
    current="${current:="/"}"
    current="/${current##/}"
    appendix="${target##/}"
    relative=''
    while appendix="${target#"$current"/}"
        [ "$current" != '/' ] && [ "$appendix" = "$target" ]; do
        if [ "$current" = "$appendix" ]; then
            relative="${relative:-.}"
            echo "${relative#/}"
            return 0
        fi
        current="${current%/*}"
        relative="$relative${relative:+/}.."
    done
    relative="$relative${relative:+${appendix:+/}}${appendix#/}"
    echo "$relative"
}
relpath "$@"
back to top