I'm having some troubled time trying to figure out how to turn on the xpg_echo option of the bash for every shell that will get run on my Linux RedHat system (7.4).
I know I can have what I need (the purpose is to expands backslash-escape at anytime as all the shells are ported from an HP-UX server) by using shopt -s xpg_echo, it's working fine for most cases.
Now my problem is where to turn on this option "system-wide" or "globally" so that every shell that I will run uses it.
I tried putting shopt -s xpg_echo into one custom shell in /etc/profile.d/myshell.sh.
It's working fine for:
- Interactive shell sessions (get's sourced from
/etc/bashrc) - Login shell sessions (get's sourced from
/etc/profile) - shell programs without a bash shebang (that is no
#!/bin/bashon 1st row)
but I can't get it to work in following cases, as it seems the /etc/profile.d/ scripts don't get sourced and the xpg_echo option is not inherited from the calling shell:
- when running a shell script (with for example
echo "a\tb") as abashargument, e.g.bash /tmp/mytest.sh - when running a shell script that has the bash shebang (
#!/bin/bash) on 1st row
I'd like to know if there is any way to turn on the shell option xpg_echo for every conditions where I need to run a shell.
NB: I'm using GNU bash, version 4.2.46
bashshell options. AFAIK,bashshell options are not inherited by child processes in the same manner as environment variables. – Kusalananda Apr 11 '19 at 15:54export xpg_echo– ron Apr 11 '19 at 17:58xpg_echois a shell option inbash, not an environment variable. Exportingxpg_echodoes nothing. – Kusalananda Apr 11 '19 at 20:21