Hacker Newsnew | past | comments | ask | show | jobs | submit | nflekkhnnn's commentslogin

Why not? History matters.


Sure, history matters, but I'll return the burden on you to argue why Israel/Palestine matters specifically in this context. Otherwise, it's irrelevant noise to the topic at hand.


No it does not imply that.


Anything other than ”#!/usr/bin/env bash” is doomed to fail at some time.


> Anything other than ”#!/usr/bin/env bash” is doomed to fail at some time.

if you have /usr/bin/env


/usr/bin/env (and /bin/sh) are part of POSIX, that is why the above shebang is the recommended way to start a shell.


/bin/sh is NOT required by POSIX, they explicitly warn that it may not exist[1].

> Applications should note that the standard PATH to the shell cannot be assumed to be either /bin/sh or /usr/bin/sh, and should be determined by interrogation of the PATH returned by getconf PATH , ensuring that the returned pathname is an absolute pathname and not a shell built-in.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/


I don't know if this is still a thing, but I distinctly remember when playing around with NixOS years ago that `env` was the only thing in /usr/bin, which I assumed was pretty much exactly for this reason.


If that fails, I assume the user knows enough about their environment to fix it.


And is this shebang guaranteed to work always? Why isn't it more common?


Because /bin is the standard location for bash. The only one that breaks that expectation is NixOS (and maybe GuixSD?), apparently. I'm surprised they didn't symlink /bin or put a stub. Last time I tried NixOS was like 10 years ago. I thought there was a /bin/bash, but maybe it was just a /bin/sh?

Other interpreters like python, ruby, etc. have more likelyhood of being used with "virtual environments", so it's more common to use /usr/bin/env with them.


/bin is the "standard" location for bash on a subset of Linux distributions and basically no other Unix...

So it's not really a standard.

/bin/sh is a much more common convention but once again, not a standard.

There really isn't a truly portable shebang, but the same can be said about executables themselves. As part of the build or install step of whatever thing you're making, you should really be looking these up and changing them.

What's more, bash isn't a standard shell.


Sorry, I should probably think more widely, but I was just considering Linux distros.

> /bin is the "standard" location for bash on a subset of Linux distributions

Considering "location" such that it includes /bin symlinks, that would be nearly all distros, I would think...

> What's more, bash isn't a standard shell.

De facto and specifically among Linux distros, it is. It's probably an underestimate that 95% of all Linux distro installations have it preinstalled.


It's only really NixOS as far as I know that doesn't ever put bash in /bin/bash (as far as Linux distributions go). But, on the other hand, there are quite a few distros (or at least flavours of distros) which don't ship bash by default (alpine, minimal versions of most distros, and embedded-Linux focused stuff if you count it). I imagine the most common "installation" of Linux is userspace in a container (yeah I know there's no kernel there, but nobody who talks about "Linux" broadly speaking specifically cares about the kernel) and a good chunk of those will be minimal with no bash.

Bash has to be explicitly installed on OpenBSD, FreeBSD, NetBSD (I think, haven't used it in a while) and probably a bunch of others. And in all of those cases (that I know of) it doesn't end up in /bin/bash once installed.

The default bash shipped on macs is so abhorrently ancient that it would be strictly better if it didn't exist because it would reduce the number of people who think bash scripts I write are broken (they're not broken, they just inevitably depend on some bash 4+ feature). Moreover, hardcoding /bin/bash as your shebang in this case will prevent anyone from remediating this problem by installing a non-ancient bash because the old one in /bin/bash will still get used.


> /bin is the "standard" location for bash on a subset of Linux distributions and basically no other Unix...

You’re forgetting macOS. It has been using /bin/bash forever.


Keep in mind that the bash you get on MacOS is bash 3.2 released in 2006 so relying on it for portability might not be a good idea.


Pretty much. I will continue using "#!/usr/bin/env <language>".


Will not wok on OpenBSD where the shell that comes with the system is ksh at /bin/ksh and /bin/sh and if you want bash it is a third party package and correspondingly gets installed as /usr/local/bin/bash

It does get awkward, especially when porting. all your third party libraries and includes are in /usr/local/lib /usr/local/include but at least it is better than freebsd which also insists on putting all third party configs under /usr/local/etc/


They do symlink /bin/sh to be fair, and that's very often good enough for a lot of scripts. That's what I usually do if I don't need anything bash offers.


Thing is, a few years ago when Debian changed its default sh from bash to ... either ash or dash, I forget which, I got into the habit of always writing `#!/bin/bash` at the top of my scripts, in case I didn't realize that something I was using was a bashism not found in classic /bin/sh. So if I used Nix (I don't, since for my particular use cases the juice isn't worth the squeeze), I would get seriously messed up by that.


/bin/sh is part of the POSIX standard -- even NixOS puts a symlink there.


It's guaranteed to work provided that Bash is in the path.

It's very common for Python. Less so for Bash for two reasons: because the person who writes the script references /bin/sh instead (which is required to be there) even when they are writing bash-isms, or because the person who writes the script assumes that Bash is universally available as /bin/bash.


It’s quite common, although I probably see it used more frequently to invoke other (non-shell) scripting languages.


Is it possible to disable xslt rendering today already, perhaps with a browser flag? For security.


The old and new json lib is written by the same person. The newer one is a bit more low-level — that’s intentional, the old one was too bloated.


Oooh, then it makes sense why there isn't a good set of layers:

XmlReader -> (XmlDocument or XmlSerializer) generally hits all use cases for serialization well. XmlReader is super-low-level streaming, when you need it. XmlDocument is great when you need to reason with Xml as the data structure, and XmlSerializer quickly translates between Xml and data structures as object serialization. There's a few default options that are wrong; but overall the API is well thought out.

In Newtonsoft I couldn't find a low level JsonReader; then in System.Text.Json I couldn't find an equivalent of mutable JObject. Both are great libraries, but they aren't comprehensive like System.Text.Json.


Google is on a trajectory to replace jpeg with webp, haven’t you noticed?


Oracle has made several open source softwares closed source. Do not trust. At all.


Why?


So ”curl news.ycombinator.com” will send you to prison?


ACI is the corresponding service in our favorite cloud.


Shut the front door!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: