7

Can install be used to install symlinks without dereferencing and installing the target file - it seems like such an unusual omission?

drwxrwxr-x 2 greg greg 4096 Aug 20 10:46 .
drwxrwxr-x 4 greg greg 4096 Aug 20 10:40 ..
lrwxrwxrwx 1 greg greg    4 Aug 20 10:46 stest -> test
-rw-rw-r-- 1 greg greg    0 Aug 20 10:40 test
$ mkdir target
$ install test  target/test
$ install stest  target/stest
$ ls -la target/
total 8
drwxrwxr-x 2 greg greg 4096 Aug 20 10:46 .
drwxrwxr-x 3 greg greg 4096 Aug 20 10:46 ..
-rwxr-xr-x 1 greg greg    0 Aug 20 10:46 stest
-rwxr-xr-x 1 greg greg    0 Aug 20 10:46 test

Is there an alternative tool that more provides the base install functionality as well as safe staging of symlinks?

3
  • PS - the obvious tag install for this question is deprecated as it has been used incorrectly for installation - perhaps it could be clarified to refer specifically to this 'standard' command-line tool.
    – Greg
    Commented Aug 21, 2015 at 6:25
  • 2
    Why not simply use ln?
    – michas
    Commented Aug 21, 2015 at 6:34
  • install allows custom setting of uid/gid and access mode, creation of directories in the path, safe handling of existing files, along with binary stripping - for my application all of these features were critical - it just chokes on symlinks. ln does none of those things.
    – Greg
    Commented Aug 21, 2015 at 12:14

1 Answer 1

1

The only workaround I have is something along the lines of:

# mess around extracting src/dest from install's $@ params
#  ...
if [ -h $src ]; then
    rm -f $dest
    [ -d $(dirname $dest) ] || install -d $(dirname $dest) ...install args... $(dirname $src)
    cp -d $src $dest
else
    install $@
fi

The mess around extracting args bit is a pain in the...

1
  • $dest isn't always the last argument of install with -t or -d. I'm unsure of interactions with -Tand symlinks. Do you have argument parsing code to share as well?
    – Tom Hale
    Commented Feb 24, 2019 at 1:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .