Skip to content

Added win32 support to ln#104

Merged
arturadib merged 1 commit intoshelljs:masterfrom
jamon:master
Feb 6, 2014
Merged

Added win32 support to ln#104
arturadib merged 1 commit intoshelljs:masterfrom
jamon:master

Conversation

@jamon
Copy link
Contributor

@jamon jamon commented Feb 4, 2014

Added win32 support to new ln command (see #87 for details)

arturadib added a commit that referenced this pull request Feb 6, 2014
Added win32 support to ln
@arturadib arturadib merged commit 945d8cc into shelljs:master Feb 6, 2014
@arturadib
Copy link
Collaborator

superb thanks!

@Schoonology
Copy link
Contributor

Actually, this breaks Windows support. The better resolution to #87 (making some assumptions around missing data) is better handling of the -f flag within our ln implementation.

@arturadib - Would you rather roll this back before a patch addressing the above, or kill two birds with one pull request (revert this behaviour and add better -f handling)?

@jamon
Copy link
Contributor Author

jamon commented Feb 25, 2014

@Schoonology - It looks like node.js fixed an issue that may make my change no longer necessary on the latest versions of node.js. In earlier versions of node.js, the only supported symlink option was "junction", and any attempt to create a symlink or hardlink would fail entirely.

It does look like the behavior on different versions of windows is still shady, though. On windows XP, -s results in a junction, on windows 7, it results in a symlink, which has different behavior (you can't cd into it using a command prompt, for example).

The questions that remains are:

What, if anything, should be done for old versions of node.js that fail on symlink creation on windows without the "junction" flag?

Is it more important to do what the user probably wants (linking directories results in things that behave like directories) and to stay consistent across versions of windows, or is it more important to do the "correct" thing and create a real "symlink" on versions of windows that support it?

My two cents is that if you choose to default to junction on windows when a symlink is requested, you'll solve both these issues... though perhaps a flag could be instituted to set which behavior is done? Though the drawback to that is that for consistency, you'd probably want to fail on older versions of windows that are currently silently creating junctions instead of "symlinks".

Thoughts?

@arturadib
Copy link
Collaborator

@Schoonology your call! I don't have windows installed (or enough windows competency) at this point to make a call :)

@Schoonology
Copy link
Contributor

@jamon - Thanks for providing your additional insight. I need to play around with directory linking more, as my current use case is all files, all the time, and I'm probably overlooking some differences in behaviour here.

That said, I believe (@arturadib this is definitely something to chime in on) that our overall goal is to replicate the behaviour of more sane shells (e.g. bash) as consistently across-the-board as possible. In that case, my feeling is to fail openly if that behaviour is completely unavailable.

As far as older versions of Node are concerned, this is a community-wide issue generally solved by erring toward the newer version. That is, if a decision will make the experience better for more recent versions at the expense of older versions, generally the newer version wins. This is in line with the intentions of Node core's progression, and should be obviated over time as the core behaviour becomes solidified.

Does that answer your questions?

@arturadib
Copy link
Collaborator

@Schoonology definitely, the goal is to avoid surprises if you're coming from unix shell, that said on Windows there's no precedent for some unix things, so in the past (I think) I've deferred to Node/libuv to normalize the behavior..

@jamon
Copy link
Contributor Author

jamon commented Feb 25, 2014

I did some digging on all of this, and it seems like the best answer is to create symlinks on OS levels that support it (Vista and later), and for earlier versions of windows, to create junctions for directories and hardlinks for files, regardless of whether the user passes -s or not.

on Windows Vista and Later, symlinks work as intended for both files and directories (I did not test hardlinks).

on Windows XP, symlinks on new versions of node.js appear to create junctions, and on old versions just error. Unfortunately, junctions don't work for files.

As a side note, I looked at cygwin to see how they handle the issue with their ln command on ntfs... which it appears that they just store info in a text file about which things are linked, so that wasn't very helpful for our discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants