Bash 5.3.0
Bash 5.3.0
I am a Fedora user so I stay cutting edge, as that is one of the key objectives of the Fedora Project. Though every once in a while, while not opting for going Rawhide (a Fedora Pre-release), I want to check out a new feature in a tool I use a lot. Well, there is probably no tool I use more than my shell
. Bash 5.3.0
Release Candidates (RC) have been available for a while and after reading an article yesterday I just had to check it out. So I went over to GNU and downloaded the latest RC for BASH 5.3.0
. I am checking it out and I like some of the new features. My system default shell is still Bash 5.2.37
. Though my local install allows me to use bash for my personal usage.
This is where how you write a shebang line really comes into play. When using multiple versions of the same shell
on a system. For instance if your shebang line was:
#!/usr/bin/bash
# My really cool script here
# ...
Then the system default would be used. The same would be true for
#!/bin/sh
and #!/bin/bash
as on modern systems they are likely just a symbolic link to /usr/bin/bash
. In fact on Fedora /bin
is a symbolic link to /usr/bin
. To be sure that my scripts use Bash 5.3.0
I use the following shebang:#!/usr/bin/env bash
# My even cooler Bash 5.3.0 script!
# ...
This works because by default,
/usr/local/bin
is before /usr/bin
on the system path. This is by design. So that local installs by your admin (which is probably you) will override system defaults. As /usr/bin/env
uses the system path to find bash
in this later shebang line example it will find my locally installed version of Bash 5.3.0
. This is preferable to hard coding where bash
is on the system. Which could change. I could later decide I wanted to use a custom build of bash
and install it in $HOME/bin
just for my personal use. As $HOME/bin
(by default) precedes both /usr/loca/bin
and /usr/bin
in the system path (this also is by design). My scripts with #!/usr/bin/env bash
will use my custom built bash
as I intended. This type of example is exactly why the POSIX standard recommends this form of shebang line.System scripts will be written with the #!/bin/sh
or #!/usr/bin/bash
form of shebang line so if they have dependencies on that version of the shell I am still safe. I have not broken my system by installing a more recent version of bash
.
note: This is also relevant to MacOS users that install the latest version of bash via homebrew
as homebrew
installs to /usr/local/bin for this reason. To replace software for the user but to leave the system software as is as the system may have dependencies on as specific version of software.
plan-A likes this.
plan-A
in reply to Unus Nemo • — (Proud Eskimo!) •@Unus Nemo
Thanks.
Mine came packed with latest it seem. NOT
not available for me yet..
sudo dnf copr enable c3d/bash
Did you compiled your version of Bash? Is only way with pgp keys ok.
You laid it out, I know
Unus Nemo
in reply to plan-A • •@plan-A
Yes as I said bash 5.2.37 is the default for Fedora. You would have to be on Rawhide Fedora to get Release Candidates (RC) which I do not recommend. Yes, I compiled my bash straight from source from the GNU GIT Server. They sign everything and it is up to you to check the signature or not. Personally I use their savannah git service to get the source from the current maintainers. Though you can download the zip file with sig file if you prefer. We both know I am not nearly as paranoid as you are so I have no issues using their git server. Please note though that any version of bash on github is not the official version. It is just a version someone is playing with. Most GNU projects today use Savannah GNU git, which belongs to GNU.
plan-A likes this.
plan-A
in reply to Unus Nemo • — (Proud Eskimo!) •I see now, thanks!
With search engine I had erronous ones..
This one it is.
savannah.gnu.org/git/?group=ba…
The GNU Bourne-Again SHell - Git Repositories [Savannah]
savannah.gnu.orgUnus Nemo
in reply to plan-A • •@plan-A
Yes, that is why I gave you the link 😉
plan-A likes this.
Unus Nemo
in reply to plan-A • •@plan-A
Keep in mind that anytime you are looking for the source for GNU software it is best to go straight to them.
plan-A likes this.
plan-A
in reply to Unus Nemo • •Roger.
Unus Nemo
in reply to plan-A • •@plan-A
You should be, it was designed that way for a reason. Often you need to maintain the outdated system version so the system will stay stable. While you provide a local copy for your users to use. They can of course if they want to use the system resource instead. Most would not want to. Keep in mind you have to have root access to install to
/usr/local/bin
just like you would to install to/usr/bin
. This system has worked quite well for over 50 years. There is no issue with it.With that said no you would not want to have a program overshadow a system program if you did not know about it. Which is why it is recommended that you not put your Present Working Directory on the system path and if you do, to add it last, never to the front of the path.
plan-A likes this.
plan-A
in reply to Unus Nemo • — (Proud Eskimo!) •55 years?? SheBang is designed to be dangerous..
And I know was for XOS from someone.
Thank you dear friend.
Unus Nemo
in reply to plan-A • •@plan-A
I correct that to 50 years. It originated in Unix. Neither
env
nor shebang was available in the original version of Unix 55 years ago (hence the correction). And the recommended way for the system path to be implemented is not dangerous at all, and neither is shebang.You should, unless you happen to be maintaining system scripts, always use the
#!/usr/bin/env bash
form and never use the fully qualified path of the software. Letenv
find it on the path. This solves many issues. Such as not all software is installed the same place on all systems. Though where it is installed is on the system path.plan-A likes this.
plan-A
in reply to Unus Nemo • — (Proud Eskimo!) •while XOS auto sets it on env one should not use it even HomeBrew.
Unus Nemo
in reply to plan-A • •@plan-A
You are confusing issues with software executing from the Present Working Directory with installed software. It is not dangerous and never has been. Homebrew uses the strategy for a reason, it was designed to work that way. Homebrew did not implement this, it is the way Unix and Unix like systems work. And it works quite well. Even without your approval 😉. You just see everything as a danger.
plan-A likes this.
plan-A
in reply to Unus Nemo • •Unus Nemo
in reply to plan-A • •@plan-A
If you need help compiling bash just read the file named
INSTALL
in the source directory.plan-A likes this.
plan-A
in reply to Unus Nemo • — (Proud Eskimo!) •4 HomeBrew, to crypt this router dns..