srsudar / eg

Useful examples at the command line.
MIT License
1.82k stars 99 forks source link

Examples don't respect links #24

Closed srsudar closed 9 years ago

srsudar commented 9 years ago

@mcarton has begun adding examples with symbolic links for aliases like netcat and nc, which are the same command. #21 and #22 are two examples. This is a good idea, and something I'd thought about doing for link and ln as well, but didn't.

The system currently isn't following these links, so this approach is failing.

Can we put symbolic links in a repo and have windows as well as *nix systems respect them? I need to look into this. If it's possible, I'll have to update the code to obey it. If not, we'll have to think of something else.

mcarton commented 9 years ago

I admit I never considered Windows while I created those symlinks. There does not seem to be a clean way to have git handle Unix symlinks on Windows. Maybe the installer could do handle that? I don't have Windows so I cannot test. Or we could add a dictionary somewhere that would be looked at when a file is not found:

synonyms = {
  'clang': 'gcc',
  'link': 'ln',
  'netcat': 'nc',
}
srsudar commented 9 years ago

The synonyms idea is a good one. There's something very elegant about the symlinks, though.

I also like having to modify as few files as possible to add an alias. Although I suppose there could a file in examples/ that is just synonyms.

I'm going to mull this over a bit and try and get ahold of a windows box to mess around with. You'd think the nix commands would be run mostly on nix machines, but people have been using them on windows a fair bit.

srsudar commented 9 years ago

It looks like Windows doesn't handle symlinks gracefully. I'll plan on adding the alias dictionary.

srsudar commented 9 years ago

In the tip there is now an examples/aliases.json file that handles aliases. So if someone wants to create an alias for link to ln, they would create a key-value pair in JSON syntax in that file.

I chose JSON because it works natively as far back as 2.6, and most importantly it is user-editable, unlike the pickle module.