Hacker News new | ask | show | jobs
by aegiso 4508 days ago
TL;DR: a 3 line exercise in bash argument munging.

  t="${!#}"
  c=("ssh" "-t" "${@:1:$(($#-1))}" "${t%:*}" "cd ${t##*:}; \$SHELL -l")
  "${c[@]}"
That's literally the whole repo.
2 comments

Literally.

We both know that it would've been easier to write this in Python, Ruby, Javascript, etc., but at the cost of using an "uncool" language I was able to solve the problem in three lines with only bash as a dependency. Pull requests welcome.

I am thankful you didn't.

Congratulations on getting the *NIX philosophy right.

http://en.wikipedia.org/wiki/Unix_philosophy

"The Unix philosophy emphasizes building short, simple, clear, modular, and extendable code that can be easily maintained and repurposed by developers other than its creators. The philosophy is based on composable (rather than contextual) design."

If that's the ★nix philosophy I don't want to be a ★nix person any more. Seriously, even my VMS machines have python installed, and a script I can read is a lot better than one I can't, even if the one I can read has an extra dependency.
Python isn't too bad (unless you're calling the script in a lot of separate instances), but python is fairly neat compared to ruby/javascript/whatever trendy language of the week as it doesn't need a huge pile of worthless dependencies itself.
Can you explain this code?
Definitely. Here's a gist, feel free to comment with any questions!

https://gist.github.com/christianbundy/8954786

Why not distribute that as the code in the repo instead of the compressed version?