Skip to content

Instantly share code, notes, and snippets.

@quackingduck
Created January 21, 2010 03:43
Show Gist options
  • Save quackingduck/282560 to your computer and use it in GitHub Desktop.
Save quackingduck/282560 to your computer and use it in GitHub Desktop.
#!/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