When we print the console settings with the echo $-
command, we output himBHs
by default. However, when we run the same command in any script file, we only output hB
.
root@root:~# echo $-
himBHs
root@root:~# ./abc.sh
hB
root@root:~#
What I'm wondering is, even though we're running the script from a /bin/bash
environment, why don't the same default settings apply ?
For example, when I start a new sub-shell process with the command /bin/bash
on the console and list the settings, I get output himBHs
.
root@root:~# /bin/bash
root@root:~# echo $-
himBHs
When I try to perform the same process from within the shell file, the output I get is "hB".
root@root:~# ./abc.sh
hB
I've tried the same process with shebang and without the shebang, but my script file is either bash script_file
or ./script_file
if I run, it gives the same result(hB
).
What exactly am I missing?
#!with /bin / bash-euxo
, we can determine the properties of the environment in which the script file will be executed. However, the same operation'#!when we try/usr/bin / env bash-euxo
, we get an error. Why? – testter Jan 28 '20 at 08:08#!/usr/bin/env command --argument
fails on Linux and How to pass arguments to the shebang interpreter when executing a script? – Inian Jan 28 '20 at 08:11