7

Consider this script.

#! /usr/bin/env bash

mkdir -p target
mkdir -p mydir/package/
touch mydir/package/file

ln --symbolic mydir mylink
file mylink

stow --verbose --dir=./mylink --target=./target package

file target/file

The output is

mylink: symbolic link to mydir
LINK: file => ../mydir/package/file
target/file: symbolic link to ../mydir/package/file

Before running stow, it looks like this:

.
├── mydir
│   └── package
│       └── file
├── mylink -> mydir
└── target

After running stow, on mylink, I expected it to look like this:

.
├── mydir
│   └── package
│       └── file
├── mylink -> mydir
└── target
    └── file -> ../mylink/package/file

However, instead it looks like this:

.
├── mydir
│   └── package
│       └── file
├── mylink -> mydir
└── target
    └── file -> ../mydir/package/file

It seems that the stow command resolves the realpath of the package directory, so instead of pointing to ../mylink/package/file it points to ../mydir/package/file.

This makes sense for avoiding too much indirection, but it happens silently and may not always be desirable. Is there a way to work around this behavior?

5

For now, there's no way.

Internally, stow find absolute canonical path of given path by using chdir to move into the path, then use getcwd() function from POSIX module, which is the Perl interface for POSIX getcwd(), to get the absolute path name.

As POSIX specified, the path name shall contain no components that are . or .., or are symbolic links.

  • 1
    Suggestions on how to fix the implementation to handle this correctly are very welcome. Pull requests are even more welcome! :-) For reference, the issue has been reported here: github.com/aspiers/stow/issues/11 – Adam Spiers Feb 27 '16 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.