Created
January 21, 2010 03:43
-
-
Save quackingduck/282560 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Save this to ~/bin/lns then never worry about the -s option and argument order | |
# for ln again | |
a,b = ARGV[0..1] | |
abort "provide source and dest, in any order" unless ARGV.size == 2 | |
if File.exist?(a) && File.exist?(b) | |
abort "both files exist" | |
elsif File.exist?(a) | |
exec "/bin/ln", "-s", a, b | |
elsif File.exist?(b) | |
exec "/bin/ln", "-s", b, a | |
else | |
abort "neither file exists" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment