Package: bash
Version: 4.1-3
Severity: normal
Despite what manual (and common knowledge/sources) say, bash'es "source"
builtin command does not seem to be fully equivalent to "." builtin command.
This shows when regarding the "export" of a variable to environment, in a
sourced subprogram. In normal interactive post-login terminal usage (both A and
B examples), it works fine:
-- START terminal A:
pawel@debiann:~$ cat test.sh
T1=1
export T2=2
pawel@debiann:~$ echo $T1 $T2
pawel@debiann:~$ . ./test.sh
pawel@debiann:~$ echo $T1 $T2
1 2
pawel@debiann:~$ bash
pawel@debiann:~$ echo $T1 $T2
2
pawel@debiann:~$
-- STOP terminal A
-- START terminal B:
pawel@debiann:~$ cat test.sh
T1=1
export T2=2
pawel@debiann:~$ echo $T1 $T2
pawel@debiann:~$ source ./test.sh
pawel@debiann:~$ echo $T1 $T2
1 2
pawel@debiann:~$ bash
pawel@debiann:~$ echo $T1 $T2
2
-- STOP terminal B:
However, when "." and "source" are used in ".bash_profile" each works
differently.
When runnning a sub-script, which uses "export" it works differently, depending
on whether "." (example C) or "source" (example D) is used.
-- START example C
pawel@debiann:~$ cat .bash_profile
.. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
pawel@debiann:~$ cat /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
-- STOP example C
-- START example D
pawel@debiann:~$ cat .bash_profile
source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
pawel@debiann:~$ cat /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
-- STOP example D
In a system booted using example C, for every later interactive terminal (in my
case "gnome-terminal" , with /bin/bash), the variable "ORACLE_HOME" will be set
with the above value.
In example D, "ORACLE_HOME" will be empty/unset/unavailable in the exported
environment.
-- System Information:
Debian Release: 6.0.3
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages bash depends on:
ii base-files6.0squeeze3Debian base system miscellaneous f
ii dash 0.5.5.1-7.4POSIX-compliant shell
ii debianutils 3.4Miscellaneous utilities specific t
ii libc6 2.11.2-10 Embedded GNU C Library: Shared lib
ii libncurses5 5.7+20100313-5 shared libraries for terminal hand
Versions of packages bash recommends:
ii bash-completion 1:1.2-3programmable completion for the ba
Versions of packages bash suggests:
pn bash-doc (no description available)
-- no debconf information
--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org