Giter VIP home page Giter VIP logo

Comments (3)

clconway avatar clconway commented on May 26, 2024

@zrlk @schroederc
This code comes from https://github.com/google/kythe/blame/master/setup_bazel.sh originally.

I notice that we always call realpath -s and we furnish the following workaround for MacOS:

realpath() {
    python -c 'import os, sys; print os.path.realpath(sys.argv[2])' $@
}

But realpath -s and os.path.realpath() don't do the same thing! E.g.,

$ realpath -s bazel-bin/../foo
/home/clconway/git/shipshape/foo
$ python -c 'import os, sys; print os.path.realpath(sys.argv[2])' -s bazel-bin/../foo
/home/clconway/.cache/bazel/_bazel_clconway/221df40891e1938542beb77d30927c8e/shipshape/bazel-out/local_linux-fastbuild/foo

I think we can easily add the workaround for non-Mac systems, but I wonder which behavior is correct?

from shipshape.

clconway avatar clconway commented on May 26, 2024

BTW I agree that readlink is probably preferable to realpath, but readlink -e also doesn't match the behavior of realpath -s.

from shipshape.

AlexTelon avatar AlexTelon commented on May 26, 2024

Indeed they are not interchangable with those flags.

Another simple way to improve the way it currently works without breaking anything is to check for realpath before first usage and give a better error message if it does not exist. Thought it might be better to only use readlink.

Something like this below, adapted from SO:

#!/bin/bash
command -v realpath >/dev/null 2>&1 || { echo >&2 "I require realpath but it's not installed.  Aborting."; exit 1; }

I tried it on my ubuntu and it worked like intended when removing and reinstalling realpath.

from shipshape.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.