HNHacker News
TopNewBestAskShowJobs

thomasbacklund

307 karma · joined February 12, 2013

https://twitter.com/Bashlund
submissionscomments
thomasbacklund··on Minimal safe Bash script template
Using `shellcheck --shell sh` is a good start :)

If adhering to POSIX it should run the same in bash, ash and dash.

Bash is kind of a moving target in it self, since it comes with many new features.

You have to be aware of which version you are targeting. For instance when using arrays, associative arrays, there is a diff between version 3 and 4.

Version 5 is even more competent and it's easy start digging to deep into the cookie jar and getting your hand stuck in there :)

thomasbacklund··on Minimal safe Bash script template
If serious about creating shell script "apps", I think standard POSIX shell is the way to go. The Bashism is seldom needed, even though it is powerful.

Why? Because shell scripting is often used in DevOps, and containers very often do not come with Bash, but with (busybox) ash or dash instead.

Say you are going FROM nginx to FROM nginx:alpine (to get that smaller image size), woha! your bash script is not working anymore.

thomasbacklund··on CLI Guidelines – A guide to help you write better command-line programs
Hey :)

Thanks for the tip! Yes, upping the site with articles and examples is on the TODO :)

In the SSH module doc [0] there are a few examples, such as:

  space -m ssh /ssh/ -e SSHHOST=jump1.example.com,jump2.example.com,jump3.example.com,destination.example.com -e SSHCOMMAND="ls -l"
One very fun feature is that you can tab auto-complete filenames and container names and also files inside container on a remote host:

  space -m ssh -e SSHHOST=1.2.3.4 -e SSHPORT=2233 -e SSHUSER=rabbit /wrap/ -m docker /wrap_exec/ -e DOCKERCONTAINER=[tab tab]
Then:

  space -m ssh -e SSHHOST=1.2.3.4 -e SSHPORT=2233 -e SSHUSER=rabbit /wrap/ -m docker /wrap_exec/ -e DOCKERCONTAINER=something -m file /cat/ -e file=/home/[tab tab]
Note that server jumping (over firewalls) is perfectly viable in the last example too, by adding more hosts (comma separated). Note that it can be important to balance host names to user names (see the doc [0]).

In the examples space wraps module functionality where the last module file is the one finally running inside the container, wrapped first by the `ssh` module then the `docker` module.

It is totally agent-less so nothing is uploaded to the server, it's just like SSHing in and running commands.

If you add the `-d` flag to space it will dump the script to output, which you can save to a .sh file and run later (without needing space.sh at all). Space it self requires bash, but the output runs with POSIX shells, so it also works with dash/ash/busybox, etc which is good because servers/containers often doesn't come with bash, but simpler ash/dash instead.

Thanks for showing interest, this makes me keen on pushing a few fixes and updates I have pending. Let me know if it doesn't work and I'll fix that :)

[0] https://space.sh/gitlab.com/space-sh/ssh/doc/master/examples...

thomasbacklund··on CLI Guidelines – A guide to help you write better command-line programs
Nice read, makes me happy to see people invest in CLI.

"Humans first"... How about "Humans with Tools first" ? :)

I would say that ALL logging should go to stderr (level should be --configurable of course), so that when running a container for example I can capture all the logging easily on stderr. Also that [WARN], [ERROR], etc tags are quite nice to have in there when grep'ing over it.. Just saying :)

I would very much recommend The Art of UNIX programming, by Eric S. Raymond [0]

I used it extensively when developing Space.sh [1] (which was an insane shell script adventure purifying for the soul, but taxing on the brain).

Going full termie is the best choice I've made, thanks for a good read! \o

[0] http://www.catb.org/esr/writings/taoup/html/ (There is a PDF available somewhere too) [1] https://space.sh/

thomasbacklund··on Traction Book – A Startup Guide to Getting Customers
Looks like an interesting read.

How big is the audio download? (I'm on a quota here in the jungle)

Can you name an Android pod app to use with it?

Thanks

thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
Good tip, you never know when it's time for SF.
thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
Welcome :)
thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
It is some of a problem. Especially because I must keep display strength to a minimum to save battery. But it works. I use the colorsheme morning (think its part of solarized) in Vim and let the sun hit the screen. And then when the screen gets to hot I move to the shade and use Jellybeans colorsheme.
thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
Agree on that. There is some overhead in making food and taking care of the camp but there is also another peace of mind that (we'll see if) could be good for your creativity.

But in either way, I feel very good on the inside now. No stress. Just harmony. Still getting a lot of things done.

thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
Exactly what my family said :) "Your doing a Doppler!"
thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
Hi peeps,

This was a nice surprise getting on HN =)

First of all, I was a weirdo before I moved to the forest. But now I'm a very happy weirdo.

I do have 4G (LTE) broad band, so Internet is almost everywhere I go.

I come from Stockholm but I live now on a trail called Sörmlandsleden, it's a 1000 km long trail and for the moment I'm pretty far south from Stockholm. But the trail never goes out "into the wild".

I also think that there is a right time for things. What I need now is to blaze forward with the coding. That's this phase.

I take swims in the lake and keep clean, shave once a week. Wash my clothes.. So when I do go into town to buy food or meet someone, I do not look like some troll. So meeting potential customers is not a big problem. I just have to get up really early in the morning to get there.. =)

I'm happy so many both here on HN and on The ListServe are interested in coding in the forest and giving support.

When winter comes I do not know what I'll do, but coding in the snow is not an option. But I will not surrender to any "normal" life until the startup begins to move, according to my earlier pledge.

Thanks!

ps. there are no bears around here.

thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
As they say "winter is coming".. Yeah, when winter does come it will be hard using the electronics.. We'll see where I'll go then I guess.
thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
Thanks, thats kind of how I see it too =)
thomasbacklund··on The entrepreneurial adventures of a coder living in a tent in the forest
Haha, yeah.. But the food poisoning come from some nasty sliced pepper salami I had for dinner. (Can't even think about them..) That was one b a d day..... Luckily a friend of mine did a rescue mission and brought me some coke and salts in the evening.. =)
← PreviousPage 2 of 2