Earlier quoted context omitted.
A use-case I've long wanted it for is better "--help" messages. If you want to tell the user how to invoke the program again, argv[0] is the right thing: Given: #include int main(int argc, char *argv[]) { printf("Usage: %s [OPTIONS]\n", argv[0]); return 0; } Running it as `./dir/demo --help` gives: Usage: ./dir/demo [OPTIONS] Put it somewhere in $PATH, and run it as `demo --help`, and it will give: Usage: demo [OPTIO…
Personally, I just don't bother trying to show the user their particular invocation: #!/bin/bash echo "Usage: $(basename $0) [OPTIONS]"
Bash 5.0 released
251–260 of 306 posts
Re: Bash 5.0 released
#252Earlier quoted context omitted.
Surely the user already knows how to invoke the program, since he/she did it literally two seconds ago. What if I invoke it from a distant path, do I want my 73 character long path to be prepended in the --help ?
Especially on something like NixOS, where /bin/bash is actually /nix/store/3508wrguwrgu3h5y9354rhfgw056y-bash-5.0/bin/bash.
If /bin/foo is actually /nix/store/3508wrguwrgu3h5y9354rhfgw056y-foo-5.0/bin/foo, then when you run "foo", 0="/nix/store/3508wrguwrgu3h5y9354rhfgw056y-foo-5.0/bin/foo" and BASH_ARGV0="foo".
Re: Bash 5.0 released
#253Earlier quoted context omitted.
It's not as nice, "cat $today" is easier to type than "cat $(today)" and would give better completion, just declared matching variables instead of matching functions, files and executables. On the plus side, TIL the subshell syntax plays well with eval/expand shortcut (ctrl+alt+e).
* "cat $today" is easier to type than "cat $(today)"* Except you should really be in the habit of typing "cat ${today}" ;)
Re: Bash 5.0 released
#254Earlier quoted context omitted.
A more syntactically friendly Haskell-like language
That’s great for developers who are competent in that paradigm but what about hobbyists or sysadmins who have little interest in software development? I’m not saying POSIX shells are without fault but they weren’t just created because C is too low level; they were created because people used a terminal who weren’t always techies so Bell Labs created a language which anyone could easily write simple programs with. Gra…
At some point when I wasn't proficient enough in Bash yet, I was writing scripts for automation using Perl and Ruby. The 'logic part' is definitely much easier in these languages. But simple file/directory stuff is far more complex actually. A lot of this has to do with error handling and different expectations how that is supposed to work. In a default shell script, errors are handled very forgivingly which is very much how most people work when performing tasks manually - not every step is super important.
On the other hand Shell scripting documentation is crap. Most of it is from 80s/90s, full of irrelevant details for the practical person. A bit like 90s/00s JS documentation before MDN.
Re: Bash 5.0 released
#255It's sad that lists.gnu.org is running obsolete TLS 1.0 crypto with weak 1024-bit DH. Either upgrade to TLS 1.2 with reasonable cipher suites, or just go back to plain HTTP.
Re: Bash 5.0 released
#256Earlier quoted context omitted.
That was kind of the idea of Unix. C was just a nicer from Assembly. You might write a performance-sensitive or low-level routine in C, much like you might drop to C when writing a Python library. But the high-level language of the system was the shell. The `dc` executable wasn't just meant to be a user-facing calculator program, it was also meant to be the system's "bignum" library. That was big-picture Unix. The sy…
Good insight, thank you
My personal take on the book is that the kernel was meant to be a portable virtual machine, extensible through processes, and that those would be the building blocks of user applications for which the shell would act as glue.
In other words, the shell and the OS are separate because most of what we commonly call "the OS" may be interpreted as mere encapsulation of less versatile hardware architectures.
Re: Bash 5.0 released
#257Seeing this release makes me cringe. I've used Bash as an interactive shell for decades but really I'm sick and tired of it. As a scripting language, I loathe it and really don't understand its purpose. I always write shell scripts in POSIX shell for portability reasons. Most of the time I don't need to use any of Bash's features. In cases where advanced features are needed and portability is not a concern, there are…
Re: Bash 5.0 released
#258Earlier quoted context omitted.
Powershell has been around for quite a while now, but only recently could you rely on it being installed on Windows systems, let alone be available on Linux. Maybe in another decade, but if you are targeting Unix-like systems bash is probably still your safest bet for portable, interpreted code. Python2 is a close second.
POSIX sh is your safest bet for portable, interpreted code.
Re: Bash 5.0 released
#259Seeing this release makes me cringe. I've used Bash as an interactive shell for decades but really I'm sick and tired of it. As a scripting language, I loathe it and really don't understand its purpose. I always write shell scripts in POSIX shell for portability reasons. Most of the time I don't need to use any of Bash's features. In cases where advanced features are needed and portability is not a concern, there are…
Re: Bash 5.0 released
#260Earlier quoted context omitted.
The remarkable consensus behind IBM's purchase of Red Hat, you mean? Seems like their highly paid lawyers were down with it. Again, it's just stunning the extent to which this FUD hasn't changed at all over a quarter century.
The GPLv3 was intentionally designed to create the risk that Apple and others are trying to avoid. IBM doesn't have that risk because they don't sell hardware or software packages, they sell expensive service contracts.
That point is silly. If what you say were true, then the purchase would have been poison. It's not true. It's FUD. And it's hilariously the same FUD that people were flinging around in years before most of the existing FUD-flingers were even born.