News for hackers. Stuff that matters.
Re:Shell Style Guide by thankthunk on Tuesday May 15, 2018 @09:43AM (#17073839)
> Do not write scripts with bash.

It's a bit too late for that. Bash is pretty much the de facto default shell for linux. Telling people not to use bash scripts is like telling web devs not to use javascript or OS devs not to use C.

It may change in the future, but bash is so entrenched, it's going to take an extraordinary use case for people to move from bash.

Re:Shell Style Guide by orzen on Tuesday May 15, 2018 @10:02AM (#17073960)
Bash is nowhere close for being de facto default shell for Linux. This is a bad analogy. In this case it is more like telling people that want to code Javascript to only write it in React. You got to go from something generic to something specific. Scripts written with bash will often rely on bash-specifics and can therefore only be interpreted by bash. There are entire projects dedicated to stop this plague. If you want to write portable shell scripts, use dash.

https://linux.die.net/man/1/checkbashisms https://mywiki.wooledge.org/Bashism https://wiki.ubuntu.com/DashAsBinSh https://en.wiktionary.org/wiki/bashism

Re:Shell Style Guide by raarts on Tuesday May 15, 2018 @10:52AM (#17074338)
> Bash is nowhere close for being de facto default shell for Linux.

Oh, yes it is. Every important distribution uses bash as the default.

Re:Shell Style Guide by umanwizard on Tuesday May 15, 2018 @11:44AM (#17074827)
Ubuntu has dash as /bin/sh.
Re:Shell Style Guide by jhasse on Tuesday May 15, 2018 @11:54AM (#17074893)
But bash as the login shell.
Re:Shell Style Guide by gkya on Tuesday May 15, 2018 @11:23PM (#17079799)
Login shell means your interactive shell. It does not necessarily mean that that shell should be used for scripting.
Re:Shell Style Guide by JdeBP on Tuesday May 15, 2018 @04:03PM (#17077360)
> It may change in the future, but bash is so entrenched, it's going to take an extraordinary use case for people to move from bash.

You don't know your history. Exactly such a move has already happened once, a decade ago. And it was a success.

* https://lists.debian.org/debian-release/2007/07/msg00027.htm...

* http://initscripts-ng.alioth.debian.org/soc2006-bootsystem/b...

* https://wiki.debian.org/BootProcessSpeedup#Using_a_faster_sy...

Re:Shell Style Guide by moviuro on Tuesday May 15, 2018 @09:51AM (#17073897)
bash is completely out of date on macOS (GPL2 vs. GPL3), and not shipped on any *BSD AFAICT.

Some Linux distro don't ship it either (void, alpine IIRC).

And, most of the time, bash is used because people don't know any better, see e.g. https://github.com/OpenRA/OpenRA/pull/8405/files

Re:Shell Style Guide by falsedan on Tuesday May 15, 2018 @11:00AM (#17074419)
> bash is completely out of date on macOS

I love finding and removing all the GNU/Linux-ism in my bash code when I move it from a dev host to my personal laptop. macOS coreutils don't have GNU longopts, surprise!

Re:Shell Style Guide by umanwizard on Tuesday May 15, 2018 @11:46AM (#17074846)
In case you didn't know: if you really need some GNU tool, you can do `brew install coreutils` (assuming you use Homebrew).

The installed binaries will have their names prefixed with `g`; e.g. `gdate` instead of `date`.

If something you want isn't part of coreutils, you can often install it directly; e.g. `brew install gawk` or the weirdly-named `brew install gnu-sed` (which names its installed binary `gsed`... go figure.)

Re:Shell Style Guide by falsedan on Tuesday May 15, 2018 @06:44PM (#17078566)
I know this; but can I teach every potential user of my scripts this same fact through documentation I have to maintain? What if: I write the code so that documenting it is easier?
Re:Shell Style Guide by gkya on Tuesday May 15, 2018 @11:24PM (#17079802)
Quite some people use Zsh interactively.
Re:Shell Style Guide by Sir_Cmpwn on Tuesday May 15, 2018 @09:49AM (#17073881)
>Telling people not to use bash scripts is like telling web devs not to use javascript or OS devs not to use C.

Wow, this comparison is totally whack. Javascript and C are both standardized and the former is the only option when using a web browser.

It's never too late. We managed to get people off of ANSI C and there's a similar amount of difference between ANSI* C and C89 as there is between bash and sh.

* correction: pre-ANSI

[dead]
Re:Shell Style Guide by Sir_Cmpwn on Tuesday May 15, 2018 @10:17AM (#17074055)
>Javascript isn't the only option. It is the most popular by far and hence the "de facto" language of the web. And javascript certainly isn't "standardized" in the sense you are writing. Do you know anything about web development, browser implementation of javascript and javascript itself? Javascript is no more "standardized" than SQL is standardized. Every RDBMs implements their own flavor of SQL just like browsers do with javascript.

This is nonsense. I am very familiar with web browsers. Javascript is standardized as ECMAScript:

https://www.ecma-international.org/publications/standards/Ec...

The "standard library" browsers implement is also standardized:

https://www.w3.org/standards/

You're off your rocker.

>Did I say it was too late? Of course I didn't. Maybe if you took a step back from your fanboyism and read...

Here is a direct quote from your comment:

>It's a bit too late for that. Bash is pretty much the de facto default shell for linux.

>ANSI C and C89 are the same thing. ANSI C is just another name for C89... Sigh...

Derp, I meant K&R C or pre-ANSI C. My mistake.

Re:Shell Style Guide by dang on Tuesday May 15, 2018 @12:33PM (#17075212)
> This is nonsense [...] You're off your rocker.

Come on Drew, you know better than to do this here, regardless of how wrong someone is. If senior users set this kind of example how can we tell new ones not to?

https://news.ycombinator.com/newsguidelines.html

Re:Shell Style Guide by Sir_Cmpwn on Tuesday May 15, 2018 @01:06PM (#17075518)
You're right, I'm sorry.
Re:Shell Style Guide by thrwwy12345 on Wednesday May 16, 2018 @10:42AM (#17082768)
> Come on Drew, you know better than to do this here, regardless of how wrong someone is.

But I wasn't wrong. I was right. But you wouldn't know that because your a gender studies major and not a CS major.

> If senior users set this kind of example how can we tell new ones not to?

And yet no flagging and no ban. How hypocritical of you. The guy instigated it and yet you banned the victim rather than the victimizer. Also senior? I've been using hacker news since the very beginning. Long before trash like you arrived daniel.

Re:Shell Style Guide by dang on Wednesday May 16, 2018 @01:57PM (#17084743)
"Regardless of how wrong someone is" does not imply that anyone was wrong. It just says that even if they're wrong, other users must remain civil. That's why we use that wording.
[dead]
Re:Shell Style Guide by dang on Tuesday May 15, 2018 @12:35PM (#17075220)
We've banned this account for repeatedly breaking the site guidelines. Would you please not create accounts to do that with?

If you don't want to be banned, you're welcome to email [email protected] and give us reason to believe that you'll follow the rules in the future.

https://news.ycombinator.com/newsguidelines.html

Re:Shell Style Guide by thrwwy12345 on Wednesday May 16, 2018 @10:43AM (#17082781)
A quick question. How proud are your parents that you moderate comments on a silly forum? Do they brag about your "career" during family gatherings on thanksgiving? Do you ever wake up and realize that you moderate comments for a living and get depressed/suicidal? Can you think of a more worthless existence that moderating comments? I commend you for not jumping in front of a train or jumping off a bridge. It takes real fortitude for someone so useless to keep going.