Package: base-files
Version: 8
Tags: patch

/etc/profile accesses some variables like $BASH and $PS1 that may be
unset, which will produce a warning or error if the (POSIX-standard)
'nounset' option is enabled.  To reproduce, run a login shell with '-u'
from a user account with no custom profile/rc/etc., e.g.,
        $ dash -u -l
        dash: 12: BASH: parameter not set
        $ posh -u -l
        posh: /etc/profile:25: BASH: parameter not set
        $ 
While it's only a warning in these examples, it would be a fatal error
if a non-interactive shell loaded /etc/profile ("A non-interactive shell
shall immediately exit").  Note that POSIX requires shells to accept -u
as a command-line argument, but not -l.

In practice the ${parameter+word} or ${parameter-word} syntaxes can be
used to avoid this problem (POSIX is silent about this, but I think it's
an oversight--it avoids a warning in every tested shell).  A trivial
patch to /etc/profile is attached.

- Michael


-- System Information:
Debian Release: 8.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: arm64

Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages base-files depends on:
ii  gawk [awk]  1:4.1.1+dfsg-1
ii  mawk [awk]  1.3.3-17

base-files recommends no packages.

base-files suggests no packages.

-- Configuration Files:
/etc/profile 91901ce5707909cfec8b3a1a6efbfa61 [Errno 2] No such file or 
directory: u'/etc/profile 91901ce5707909cfec8b3a1a6efbfa61'

-- no debconf information
--- /etc/profile	2014-10-22 10:02:30.000000000 -0400
+++ profile	2015-01-24 11:51:39.272067172 -0500
@@ -8,8 +8,8 @@
 fi
 export PATH
 
-if [ "$PS1" ]; then
-  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
+if [ "${PS1-}" ]; then
+  if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
     # The file bash.bashrc already sets the default PS1.
     # PS1='\h:\w\$ '
     if [ -f /etc/bash.bashrc ]; then

Attachment: signature.asc
Description: Digital signature

Reply via email to