Blue light is scattered in all directions by the tiny molecules of air in Earth's atmosphere. Blue is scattered more than other colors because it travels as shorter, smaller waves. This is why we see a blue sky most of the time.
The sky during the day During the day the sky looks blue because it's the blue light that gets scattered the most. It's redirected into many different directions all over the sky, whereas the other wavelengths aren't scattered as much.
You asked about the sky. We know the sky is blue and the sea does reflect some of this light. So, yes, it does play a role. To sum it all up: the sea is blue because of the way water absorbs light, the way particles in the water scatter light, and also because some of the blue light from the sky is reflected.
Greg then demonstrates that the graphs for sky colour and atmospheric pressure are a very close match. He finishes by explaining that the sunlight is scattered by the Earth's atmosphere and that this effect increases as the atmosphere gets denser near the Earth's surface. This makes the sky look blue.
#!/usr/bin/env
searches PATH
for bash
, and bash
is not always in /bin
, particularly on non-Linux systems. For example, on my OpenBSD system, it's in /usr/local/bin
, since it was installed as an optional package.
If you are absolutely sure bash
is in /bin
and will always be, there's no harm in putting it directly in your shebang—but I'd recommend against it because scripts and programs all have lives beyond what we initially believe they will have.
The standard location of bash is /bin
, and I suspect that's true on all systems. However, what if you don't like that version of bash? For example, I want to use bash 4.2, but the bash on my Mac is at 3.2.5.
I could try reinstalling bash in /bin
but that may be a bad idea. If I update my OS, it will be overwritten.
However, I could install bash in /usr/local/bin/bash
, and setup my PATH to:
PATH="/usr/local/bin:/bin:/usr/bin:$HOME/bin"
Now, if I specify bash
, I don't get the old cruddy one at /bin/bash
, but the newer, shinier one at /usr/local/bin
. Nice!
Except my shell scripts have that !# /bin/bash
shebang. Thus, when I run my shell scripts, I get that old and lousy version of bash that doesn't even have associative arrays.
Using /usr/bin/env bash
will use the version of bash found in my PATH. If I setup my PATH, so that /usr/local/bin/bash
is executed, that's the bash that my scripts will use.
It's rare to see this with bash, but it is a lot more common with Perl and Python:
/bin
? /usr/bin
? /opt/bin
? Who knows? Using #! /usr/bin/env perl
meant I didn't have to know.#! /usr/bin/env bash
When the path is hardcoded in the shebang, I have to run with that interpreter. Thus, #! /bin/bash
forces me to use the default installed version of bash. Since bash features are very stable (try running a 2.x version of a Python script under Python 3.x) it's very unlikely that my particular BASH script will not work, and since my bash script is probably used by this system and other systems, using a non-standard version of bash may have undesired effects. It is very likely I want to make sure that the stable standard version of bash is used with my shell script. Thus, I probably want to hard code the path in my shebang.
For invoking bash
it is a little bit of overkill. Unless you have multiple bash
binaries like your own in ~/bin but that also means your code depends on $PATH having the right things in it.
It is handy for things like python
though. There are wrapper scripts and environments which lead to alternative python
binaries being used.
But nothing is lost by using the exact path to the binary as long as you are sure it is the binary you really want.
There are a lot of systems that don't have Bash in /bin
, FreeBSD and OpenBSD just to name a few. If your script is meant to be portable to many different Unices, you may want to use #!/usr/bin/env bash
instead of #!/bin/bash
.
Note that this does not hold true for sh
; for Bourne-compliant scripts I exclusively use #!/bin/sh
, since I think pretty much every Unix in existence has sh
in /bin
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With