Live data from Hacker News

Bash 5.0 released

lists.gnu.org

101–110 of 306 posts

Re: Bash 5.0 released

#101
post #84

With this release, bash now has three built-in variables (um, I mean "parameters") whose values are updated every time they're read: $RANDOM yields a random integer in the range 0..32767. (This feature was already there.) $EPOCHSECONDS yields the whole number of seconds since the epoch. $EPOCHREALTIME yields the number of seconds since the epoch with microsecond precision. I'm thinking of a new shell feature that wou…

[deleted]

Re: Bash 5.0 released

#102
post #95
post #90

Earlier quoted context omitted.

> accidentally shipping it on iOS can be pretty dangerous I read the same argument about GPLv2 in like 1994. To date, there remains no case law I'm aware of where a copyright holder "lost" anything by "accidentally" shipping GPL software. How many decades does it take for us to put this myth to rest?

A lot, because it's hard to derive meaningful conclusions from something that's used so relatively little precisely because of licensing concerns. Anyway, with v2, the concerns were more vague - you'd have to accidentally link something GPLv2. With v3, even just shipping the binary signed with a private key on a platform that requires said key to load it, is enough to potentially force disclosure of that key (and tha…

Right, so the risk can't be quantified and the whole thing is just isomorphic "because I don't like it". Which was as true then as it is now. It's not about license terms, it's about what amounts to politics.

Re: Bash 5.0 released

#103
post #41
post #36

Earlier quoted context omitted.

It's strange to me to imagine that there would be one language that was the best choice for OS implementation and day to day user interaction/automation. I'm curious what language do you think would be good for both use cases?

A more syntactically friendly Haskell-like language

How would you deal with mutable state like, say, the current directory?

Re: Bash 5.0 released

#104
post #84

With this release, bash now has three built-in variables (um, I mean "parameters") whose values are updated every time they're read: $RANDOM yields a random integer in the range 0..32767. (This feature was already there.) $EPOCHSECONDS yields the whole number of seconds since the epoch. $EPOCHREALTIME yields the number of seconds since the epoch with microsecond precision. I'm thinking of a new shell feature that wou…

[deleted]

Re: Bash 5.0 released

#105

Earlier quoted context omitted.

It seems like this would eliminate the need to read a file from disk and fork a new process, both of which take time. If you're just removing a single file, this is probably negligible, but if you have a script iterating over 10k files, i.e., this speed-up may be more welcome.

> if you have a script iterating over 10k files That's probably a good sign you should advance from shell. If the script is trivial, it's going to be trivial in python / ruby / go / crystal / ... as well. If it's not trivial, that's another reason to move.

I agree that as scripts get more complex, you should migrate from bash. But the number of files a script touches says almost nothing about its complexity.

Re: Bash 5.0 released

#106
post #91

Earlier quoted context omitted.

Sorry I don’t know anything about how Bash is implemented, but when someone assigns to that variable Bash just needs to write that string to argv.

I tried python, bash and even C, none of them update /proc/self/comm when argv[0] is updated: dualbus@system76-pc:~$ cat argv0.c #include #include int main(int argc, char **argv) { FILE *fp; char buf[256]; // XXX :-) strcpy(argv[0], "XYZ"); //puts(argv[0]); fp = fopen("/proc/self/comm", "r"); fread(&buf, 1, 256, fp); buf[255] = '\0'; puts(buf); } dualbus@system76-pc:~$ gcc -o argv0 argv0.c -Wall dualbus@system76-pc:~…

    $ ruby -e "\$0 = 'im not lying to you'; sleep"
    $ ps

Re: Bash 5.0 released

#107
post #97
post #91

Earlier quoted context omitted.

I tried python, bash and even C, none of them update /proc/self/comm when argv[0] is updated: dualbus@system76-pc:~$ cat argv0.c #include #include int main(int argc, char **argv) { FILE *fp; char buf[256]; // XXX :-) strcpy(argv[0], "XYZ"); //puts(argv[0]); fp = fopen("/proc/self/comm", "r"); fread(&buf, 1, 256, fp); buf[255] = '\0'; puts(buf); } dualbus@system76-pc:~$ gcc -o argv0 argv0.c -Wall dualbus@system76-pc:~…

You're looking at the wrong file. Setting argv[0] doesn't update /proc/self/comm, it updates /proc/self/cmdline. demo.c: #include #include int main(int argc, char *argv[]) { strcpy(argv[0], "frob"); sleep(100); } Terminal 1: $ make demo cc demo.c -o demo $ ./demo --greppable Terminal 2: $ ps aux|grep greppable luke 25858 0.0 0.0 2164 752 pts/0 S+ 00:32 0:00 frob o --greppable luke 25931 0.0 0.0 8192 2356 pts/5 S+ 00:…

[deleted]

Re: Bash 5.0 released

#108
post #53

Earlier quoted context omitted.

On macOS almost everyone uses the homebrew package manager https://brew.sh . Installing bash is harder because you have to add the filepath of the new bash binary to /etc/shells and then set that filepath as your default shell, but brew install bash echo /usr/local/bin/bash | sudo tee -a /etc/shells chsh -s /usr/local/bin/bash and if you're on macOS and still haven't heard of homebrew, you first need to install it wi…

That command makes my eyes twitch. This sort of "download random stuff from internet, then pipe them to ruby/perl/python" madness should end, like right now. I'm assuming you're a reasonable person who knows what that commands does. Can you really not see how people can misuse commands like this to execute arbitrary code on people's computers, even experienced engineers if they carelessly copy-paste code like this. A…

Alternatively, follow the homebrew installation instructions: https://docs.brew.sh/Installation

Re: Bash 5.0 released

#109
post #13

Earlier quoted context omitted.

I recommend Greg's Bash Wiki ... https://mywiki.wooledge.org/BashGuide . See general notes, then at the bottom of the page are many links to additional considerations. Like others say, "bash" is a hard tool to get right (and I'm not saying I do it right either, necessarily, but Greg's Wiki was real helpful!). I'm building a hybrid bash/python3 environment now (something I'll hopefully open-source at some point), and…

It is availbale, almost, everywhere but be careful with the version, different Linux diatros are at different versions, the last time I used OSX it was stuck on a very old version, and I expect the different BSD OSes to run fairly new versions.

BSDs don't ship Bash as part of the base system - you have to install it from packages or ports. And that one is the most recent that the maintainer bothered to package. E.g. FreeBSD is on 4.4.23 right now, which actually appears to be newer than e.g. Debian unstable.

Re: Bash 5.0 released

#110
post #84

With this release, bash now has three built-in variables (um, I mean "parameters") whose values are updated every time they're read: $RANDOM yields a random integer in the range 0..32767. (This feature was already there.) $EPOCHSECONDS yields the whole number of seconds since the epoch. $EPOCHREALTIME yields the number of seconds since the epoch with microsecond precision. I'm thinking of a new shell feature that wou…

$RANDOM is new in bash 5.0? i'm curious. This has been documented for ages, afaik. headtilt
Post reply on HN