Live data from Hacker News

Stronger Shell

m.odul.us

21–30 of 80 posts

Re: Stronger Shell

#21
interviewers tend not to test for shell skill even though your shell skills are usually more relevant to daily tasks. I'm debating whether to improve on my shell skills or algorithm skills.

Re: Stronger Shell

#22
post #6

I personally can't stand bash for writing scripts (it's fine for typing one-liners into terminal though). This question and its top answer capture the insanity of bash quite nicely http://stackoverflow.com/questions/3601515/how-to-check-if-a... .

I've seen a lot of tools I use migrate from using sh wrappers to python wrappers. My observation is that it's nearly impossible to read and suffers extreme featureitis because "batteries are included".

Re: Stronger Shell

#23
I've found that as soon as bash script goes to more than a couple lines, or as soon as it needs anything modestly complex, like "if" statements or functions, then it is almost always more efficient to write it in ipython. If you know python, then ipython is really superior way to do any ops and administration tasks. I've also found it easier to use for server setup than alternatives like ansible or puppet. I can just use standard, reusable classes and functions to do all my various activities.

Re: Stronger Shell

#24
Confession: The horrors of bash set back my programming hobby until high school. Even then, I didn't actually like interacting with my computer programmatically until I found a comfortable set of tools sometime in college. I'm lucky that my day job lets me use the tools I like and avoid systems like the bash shell.

Re: Stronger Shell

#25
post #17
post #13

Earlier quoted context omitted.

> Is there a better shell? By which I mean more flexible, more consistent, and simpler. Yes, PowerShell. And it may actually arrive at Linux/Unix soon, due to CoreCLR. The specification is already open, but until now not much progress has been made towards bringing it uncrippled to Linux/Unix PowerShell is extremely consistent. Examples: All commands are strictly on the verb-noun form where there are only 40 or so "a…

Can you recommend a resource for learning powershell? (Assuming one has UNIX background) [it does generate annoyingly long error messages!]

Long error messages: Yes, they can be a little strange at first. If they annoy you (or you want errors to cause a little less scrolling) you can set the "error view":

    $ErrorView = "CategoryView"
(unlike bash, whitespace is not significant)

As for learning PowerShell, if you lean towards online training, Microsoft Virtual Acedemy has a really good series of courses, even featuring Jeffrey Snover - who is surprisingly good at explaining stuff.

This is a good starting point:

https://www.microsoftvirtualacademy.com/en-US/training-cours...

I usually prefer books/articles etc where I can set my own pace, but those online courses are really that good.

Otherwise links: * https://technet.microsoft.com/en-us/library/cc281945(v=sql.1... * http://learn-powershell.net/

And let's not forget the very friendly community at http://powershell.org/ with articles such as this one: http://powershell.org/wp/2015/07/31/introduction-to-powershe...

Re: Stronger Shell

#26
post #6

I personally can't stand bash for writing scripts (it's fine for typing one-liners into terminal though). This question and its top answer capture the insanity of bash quite nicely http://stackoverflow.com/questions/3601515/how-to-check-if-a... .

> This is because it doesn't distinguish between a variable that is unset and a variable that is set to the empty string.

Yeah, this is insane and the default settings of bash are quite horrible. You can set some bash options in the beginning to avoid such problems. For the StackOverflow problem "set -o nounset" can be a good safeguard. Other options to look into to safeguard bash scripts from some insane behavior are "errexit" and "pipefail". Even though setting these is good practice, it doesn't stop some stuff that could be expected to be stopped by these. These options are not inherited to subshells invoked by command substitution and the likes. They wouldn't have stopped this nasty steam bug [1] for example. There are other nasty quirks too, it's really hard to unfck bash.

[1] https://github.com/ValveSoftware/steam-for-linux/issues/3671...

Re: Stronger Shell

#27
post #3

actually [ is same as test and the last ] is just the last (useless) argument of [ , iirc

Actually you most probably have /bin/[ on your filesystem as a standalone 'test' executable or a link to 'test'. [ is a shell builtin in bash though.

Re: Stronger Shell

#28

Confession: The horrors of bash set back my programming hobby until high school. Even then, I didn't actually like interacting with my computer programmatically until I found a comfortable set of tools sometime in college. I'm lucky that my day job lets me use the tools I like and avoid systems like the bash shell.

Interestingly my experience has been opposite. My first programming adventure was automating some file validation using bash. I agree though that the silly and inconsistent syntax made me really appreciate python when I started learning it.

Re: Stronger Shell

#29
Just about everything I've learned about bash has been from the #bash IRC channel on Freenode. You'll see the same repeated warnings of not learning from the public web, due to the fact that misinformation spreads like a wild fire, and some articles out there are just flat out wrong (sort of like w3schools in the #css circle).

There is just one thing I will never understand. The tired argument of "...but it isn't portable". Features that are new, and make programming bash easier (such as "[" vs "[["), are looked down upon in some circles because it isn't portable. If I'm programming for bash, then upon deployment, I'll be using bash. To use another shell, and hope it just works is a bit insane.

I'd also like to second using the Fish shell. Far better than bash/zsh for everyday use, and I just can't go back to other shells.

Re: Stronger Shell

#30
post #7

If you're writing shell scripts, you might as well write Ansible playbooks. You can use Ansible playbooks locally without the SSH layer. Bash/sh is a horrible programming language.

[deleted]
Post reply on HN