Live data from Hacker News

Shell Style Guide

google.github.io

281–290 of 336 posts

Re: Shell Style Guide

#281
post #8
post #4

Earlier quoted context omitted.

I’ve actually seen this happen. It’s terrifying.

Sure, but not as terrifying as people rewriting shell one-liners in python or (gasp) java.

I hope there was a reason for rewriting them.. Anyway Java is for sure NOT a scripting language. F# is much much better from that point of view, with the right tools, but sadly it is not famous enough.

Re: Shell Style Guide

#282

I don’t understand all the hate for bash or python in this thread. These are programming languages. Like all programming languages one must understand how to deploy them and use them properly. Yes bash has faults absolutely. It can be very arcane and esoteric and I think this due to the fact that it’s creators are very much of the old 1970s and 1980s Unix mindset and largely bash tools still feel like they work the w…

> due to the fact that it’s [sic] creators are very much of the old 1970s and 1980s Unix mindset Firstly, Bash is relied upon to conform to a standard; it's not an exploratory project which expresses the maintainers' views about what a shell should look like. Secondly, Stallman didn't start Bash because he loved Unix. It was a pragmatic choice. Stallman really wanted a free platform based on Lisp. He went with clonin…

Yeah, when you dig down into the specifics I was not doing the history justice. My broader point was that it was definitely designed in a different era, with a different mindset, and has still managed to persist to this day, without that mindset shifting very much (usually for good reasons, or backward compatibility, which may or not be a good reason depending on specific circumstances)

I often wonder if shell scripts would get such a bad wrap if all the backwards compatible code was strip out and only the latest standards were put in. I think thats where it gets people so very confused & it definitely feels awkward.

I think its actually a perfectly fine language, syntactically speaking.

Re: Shell Style Guide

#283
post #5

The only thing I'd quibble with is the recommendation of [[ ... ]] over [ ... ], because shell programmers used to [ will be surprised that [[ "foo" == "f*" ]] does pattern matching. But that is more or less an arbitrary style preference. One thing I'm curious about is whether Google machines have followed Debian etc. in making /bin/sh a faster non-bash shell, or if /bin/sh is bash.

> One thing I'm curious about is whether Google machines have followed Debian etc. in making /bin/sh a faster non-bash shell, or if /bin/sh is bash.

Since the guide says "Executables must start with #!/bin/bash" it doesn't really matter.

Re: Shell Style Guide

#284

Earlier quoted context omitted.

I used Powershell extensively before I ever had experience with a linux or unix shell. I still have more experience with Powershell than bash or zsh, but I can't imaging going back. I'm already much more capable in a *nix shell. There are advantages to having a pipe based on structured data, but that also means you have to know what structure to expect at ever step of the way and whether or not other tools can work w…

Passing text means that every single one of the thousands and thousands of unix cli tools that accept stdio will work in your pipeline. It also means every one of those thousands and thousands of Unix clip tools needs to have a parser to turn that text into some sort of structure to operate on.

Which allows them to determine exactly the best way to do that for their purposes. I just run the command and it magically works.

It'll be a long time before the Powershell ecosystem has a fraction of tools that are compatible with it's .NET object pipeline.

Re: Shell Style Guide

#285

Original HN title had the word "Google" in it. According to this document, Google requires Bash. I do not use Bash. I use Almquist shell. I try to avoid using uncommon "features" or utilities. I am not a frequent Linux user but whenever I have to use it, all of the hundreds of scripts I wrote using another OS and Almquist shell still work. They all work in Bash. Over the years, I used this site as a reference: https:…

They require bash for scripts.

You can use whatever shell you like on your machines.

Re: Shell Style Guide

#286
post #273

I don’t understand all the hate for bash or python in this thread. These are programming languages. Like all programming languages one must understand how to deploy them and use them properly. Yes bash has faults absolutely. It can be very arcane and esoteric and I think this due to the fact that it’s creators are very much of the old 1970s and 1980s Unix mindset and largely bash tools still feel like they work the w…

> I think this due to the fact that it’s creators are very much of the old 1970s and 1980s Unix mindset The Bourne Again shell was created in 1989. That said, the 1980s Unix mindset was not what you clearly think it to be. It was full of Sun workstations, NextStep, Orthodox File Manager clones, Terminals with graphics, GNU Screen, Threaded ReadNews, ...

Yes indeed, it sure was. I realize that. Don't forgot those awesome Amiga workstations

https://en.wikipedia.org/wiki/Amiga#/media/File:Amiga500_sys...

Way ahead of their time, those guys.

I don't think my point glosses over this at all though, in that the mindset back then derived from the pioneering work done at Xerox Labs & on original Unix. I know bash itself was not created as the first shell implementation, however its syntax is clearly heavily derived from the original Bourne shell and ascribed to its overall philosophy: do one thing, and do one thing well. Besides, at that time, you either dropped into Smalltalk or C if you needed to do more than text processing, which is what bash et. al. are still insanely good for.

Re: Shell Style Guide

#287
post #226
post #148

Earlier quoted context omitted.

Sad to see this downvoted. As a 20 year bash veteran: powershell is the first OS default shell that outputs structured data, and looking at objects and selecting the properties you want is a massive improvement than combining bash with sed/grep/awk to scrape text. Someone bizarrely responds that cmd still exists on Windows for compatibility purposes (though even Win+X starts powershell now) doesn't change this at all…

I'm always amused by these PowerShell threads on HN. How is it that objects are an accepted thing for basically every programming environment in modern use, yet somehow controversial when it comes to the shell? The prayer-based text parsing toolchain sucks. It has always sucked, regardless of platform. We put up with it because it was all that we had. Jeffrey Snover came up with something better and thanks to PS Core…

> How is it that objects are an accepted thing for basically every programming environment in modern use,

They aren't accepted for basically every programming environmental nment in modern use; peak OOP-all-the-things is well in the past, and it's no longer the one paradigm to rule them all, irrespective of use case.

Re: Shell Style Guide

#288

I don’t understand all the hate for bash or python in this thread. These are programming languages. Like all programming languages one must understand how to deploy them and use them properly. Yes bash has faults absolutely. It can be very arcane and esoteric and I think this due to the fact that it’s creators are very much of the old 1970s and 1980s Unix mindset and largely bash tools still feel like they work the w…

> no single language is objectively superior to another I would say some languages are objectively superior to other for specific tasks. The problem is that very often the task to solve doesn't exactly fall within the realm of any given programming language and one has to make compromise. As for bash, I use it when I feel it's the best option, but I also think it's the worst programming language that I have to use. I…

Try fish shell. Not too different but not as bad.

https://fishshell.com

And an effort to get rid of bash as Oil shell. (They really need a better name for Googleability.)

https://www.oilshell.org

Re: Shell Style Guide

#289
post #226

Earlier quoted context omitted.

I'm always amused by these PowerShell threads on HN. How is it that objects are an accepted thing for basically every programming environment in modern use, yet somehow controversial when it comes to the shell? The prayer-based text parsing toolchain sucks. It has always sucked, regardless of platform. We put up with it because it was all that we had. Jeffrey Snover came up with something better and thanks to PS Core…

> How is it that objects are an accepted thing for basically every programming environment in modern use, They aren't accepted for basically every programming environmental nment in modern use; peak OOP-all-the-things is well in the past, and it's no longer the one paradigm to rule them all, irrespective of use case.

Whether you have methods or functions, you still have hashmaps - bash you scrape values, pwsh you select keys. Pipelines can be considered quite functional too.

Re: Shell Style Guide

#290

Original HN title had the word "Google" in it. According to this document, Google requires Bash. I do not use Bash. I use Almquist shell. I try to avoid using uncommon "features" or utilities. I am not a frequent Linux user but whenever I have to use it, all of the hundreds of scripts I wrote using another OS and Almquist shell still work. They all work in Bash. Over the years, I used this site as a reference: https:…

They require bash for scripts. You can use whatever shell you like on your machines.

"They require Bash for scripts."

I do not write scripts to run with Bash. I write them to run with an Almquist-derived shell, which also means I can run them with Bash and other shells without any problems. However a script written in Bash may not run correctly under Almquist shell and other shells.

Post reply on HN