Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Permit to use a single symlink as installation method #42

Merged
merged 1 commit into from
Nov 23, 2012
Merged

Permit to use a single symlink as installation method #42

merged 1 commit into from
Nov 23, 2012

Conversation

baby-gnu
Copy link

This patch permit to create a link in $PATH pointing to sources.

  • git-flow (GITFLOW_DIR): dereference $0 to handle symlink.

This patch permit to create a link in $PATH pointing to sources.

* git-flow (GITFLOW_DIR): dereference $0 to handle symlink.
@petervanderdoes petervanderdoes merged commit f61656d into petervanderdoes:develop Nov 23, 2012
@petervanderdoes
Copy link
Owner

Going to reverse this as Mac's can't handle readlink -e or readlink -f. What was the real purpose of this, I forgot.

@baby-gnu
Copy link
Author

Sorry, I was not aware of the limitations of proprietary softwares.

The idea behind using readlink -e "$0" instead of just $0 was to install git-flow with only the two following commands:

git clone https://github.com/petervanderdoes/gitflow.git
ln -s $(pwd)/gitflow/git-flow ~/bin/git-flow

Some updating the software only needs to pull the git repository, testing new functionality only needs to switch branches.

If the problem causing the revert is just that the readlink command is not available, then I could provide something like:

if type -p readlink > /dev/null
    SELF=$(readlink -e "$0")
else
    SELF="$0"
fi
export GITFLOW_DIR=$(dirname "$(echo "$SELF" | sed -e 's,\\,/,g')")

@talios
Copy link
Contributor

talios commented Dec 13, 2012

It's not so much that its not available, but that the arguments differ slightly. I suspect this may be another of those GNU vs BSD version issues. An extract from the man page:

NAME
     readlink, stat -- display file status

SYNOPSIS
     stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
     readlink [-n] [file ...]

DESCRIPTION
     ....
     The options are as follows:

     -F      As in ls(1), display a slash (`/') immediately after each pathname that is a directory, an asterisk
             (`*') after each that is executable, an at sign (`@') after each symbolic link, a percent sign (`%')
             after each whiteout, an equal sign (`=') after each socket, and a vertical bar (`|') after each that is
             a FIFO.  The use of -F implies -l.

     -f format
             Display information using the specified format.  See the FORMATS section for a description of valid for-
             mats.

     -L      Use stat(2) instead of lstat(2).  The information reported by stat will refer to the target of file, if
             file is a symbolic link, and not to file itself.

     -l      Display output in ls -lT format.

     -n      Do not force a newline to appear at the end of each piece of output.

     -q      Suppress failure messages if calls to stat(2) or lstat(2) fail.  When run as readlink, error messages
             are automatically suppressed.

     -r      Display raw information.  That is, for all the fields in the stat structure, display the raw, numerical
             value (for example, times in seconds since the epoch, etc.).

     -s      Display information in ``shell output'', suitable for initializing variables.

     -t timefmt
             Display timestamps using the specified format.  This format is passed directly to strftime(3).

     -x      Display information in a more verbose way as known from some Linux distributions.

@glittershark
Copy link

There's a package greadlink available in homebrew that replicates the GNU readlink functionality with -f etc.

@baby-gnu
Copy link
Author

Well, in our case, the -e option is useless as "$0" obviously exists because we are in it ;-)

@petervanderdoes
Copy link
Owner

The -e option makes readlink return the absolute name, if the link is relative. We need absolute in our case. I have worked on this a bit and so far I've got it working for Linux, *BSD and I think OSX, but it's late, time for bed. Will push something tomorrow

@petervanderdoes
Copy link
Owner

OK, it's tomorrow :) Just pushed version 1.4.0-dev.22 which hopefully resolves this issue for the different platforms. I created issue #48 to help test this for all different operating systems.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants