Bug #3781


ksh93's builtin ln inconsistent

Added by Garrett D'Amore about 10 years ago. Updated about 2 years ago.

cmd - userland programs
Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:
External Bug:


I found cases where -f is not honored properly with ksh. I can't figure out why.

Processing ksh-overrides: ./src/scripts/mk-dist2101: process_pkgs1128: process_pkg732: process_pkg_line685: pkg_directive_link409: ln: ../../sbin/sh: cannot link to /tmp/DEYOS.out/mnt/usr/bin/sh [File exists]

The source for this routine looks like this:

${X_LN} -sf "$1" "$2" || die "ln -sf $1 $2"

Notably, X_LN evaluates to "ln".

In my script, I was able to workaround this like this:

${X_LN} -sf "$1" "$2" 2> /dev/null || \\
${E}/usr/bin/ln -sf "$1" "$2" || die "ln -sf $1 $2"

This is key, because I don't want to always execute the ln -- this script does a lot of these and it takes too long if I have to shell out all the time.

This similar to 3779.

Actions #1

Updated by Irek Szczesniak about 10 years ago

Bug passed to upstream. May take a week or two to get feedback because the AST and UWIN projects are currently under lockdown to merge several project branches into the mainline.

Actions #2

Updated by Irek Szczesniak about 10 years ago

Glenn Fowler asked:
can you make a small test case (like the previous /tmp/x => /tmp/g) that
shows the problem

I'm asking because the first thing I tried worked [comment: Glenn is using ast-ksh.2013-05-03. Its very possible that either Glenn or Roland killed that bug since the last time ksh93 was updated in Illumos]

Actions #3

Updated by Garrett D'Amore about 10 years ago

I know how to isolate this. Individual small tests seem to pass just fine, this is in the context of a much larger script that issues thousands of these operations before falling over on this one. I'm stumped.

Actions #4

Updated by Garrett D'Amore about 10 years ago

One possible point, these ln -sf may point to a target that is missing, or may cross a filesystem boundary, if either of those help. Not sure. I'll try some tests later to isolate. But I'm running pretty old ksh right now... illumos last updated in 2009.

Actions #5

Updated by Andy Fiddaman about 2 years ago

  • Status changed from New to Closed

I can't replicate this with the 2020 gate ksh (Version JM 93t+ 2010-03-05) or the current one (Version jM 93u+ 2012-08-01)
This was likely fixed in a version after the reporter's ksh from 2009.

If it is still a problem with the current gate ksh, please re-open. truss/dtrace output would be very useful in tracking this down if a simple test case can't be found.


Also available in: Atom PDF