bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

HOME variable not set when using -l option


From: Audrius Butkevicius
Subject: HOME variable not set when using -l option
Date: Mon, 13 Jan 2014 15:25:00 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0


Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE uname output: Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 45
Release Status: release

Description:

        Login shell not setting HOME variable when using -l option,
        but is set when using - as argument zero. This is not
        differentiated in the documentation,

        "A login shell is one whose first character of argument zero
        is a -, or one started with the --login option."

        therefore I assume it is a bug.

        I would expect consistent behavior between the two methods
        of acquiring a login shell.

Repeat-By:

        address@hidden:~# unset HOME

        address@hidden:/root# /bin/bash -l
        address@hidden:/root# cd
        bash: cd: HOME not set
        address@hidden:/root# logout
        address@hidden:/root#

        address@hidden:/root# argv0 /bin/bash -
        address@hidden:~# cd
        address@hidden:~# logout
        address@hidden:/root#

        address@hidden:/root# argv0 /bin/bash - -l
        address@hidden:/root# cd
        bash: cd: HOME not set
        address@hidden:/root# logout
        address@hidden:/root#

Fix:

        The line numbers I am referring to below are of revision
        f281b8f4f8936b2713966274d9f8508a9f0910e4.

        When we use the -l option, the value of login_shell is
        incremented and then inverted in line 478 of shell.c, and
        line 486 of variables.c relies on the value being equal to
        1, which I believe is wrong.

        As a reference, the only reliance on the value being
        negative is in line 1047 of shell.c.

Patch:

diff --git a/patchlevel.h b/patchlevel.h
index d959843..f5e2525 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */

-#define PATCHLEVEL 45
+#define PATCHLEVEL 46

 #endif /* _PATCHLEVEL_H_ */
diff --git a/variables.c b/variables.c
index 7bb850f..c90b8dd 100644
--- a/variables.c
+++ b/variables.c
@@ -483,7 +483,7 @@ initialize_shell_variables (env, privmode)
   bind_variable ("OPTERR", "1", 0);
   sh_opterr = 1;

-  if (login_shell == 1 && posixly_correct == 0)
+  if (login_shell && posixly_correct == 0)
     set_home_var ();

   /* Get the full pathname to THIS shell, and set the BASH variable




reply via email to

[Prev in Thread] Current Thread [Next in Thread]