#48 profile: Don't overwrite the HISTSIZE environment variable
Merged 3 months ago by mosvald. Opened 5 months ago by rishi.

file modified
+4 -1
@@ -46,7 +46,10 @@ 

  HOSTNAME=$(/usr/bin/hostname 2>/dev/null) || \

  HOSTNAME=$(/usr/bin/uname -n)

  

- HISTSIZE=1000

+ if [ -z "$HISTSIZE" ] ; then

+     HISTSIZE=1000

+ fi

+ 

  if [ "$HISTCONTROL" = "ignorespace" ] ; then

      export HISTCONTROL=ignoreboth

  else

Currently, the HISTSIZE environment variable is always set to 1000,
regardless of whether it might have been set to a different value before
starting this instance of Bash.

This mostly worked fine, because chances are high that any system or
user specific HISTSIZE customization would have happened through one of
the Bash configuration scripts in /etc/profile.d or $HOME that are read
after /etc/profile. So, the customized value had priority.

However, this creates problems in interactive Bash instances running
inside a container, if the system specific HISTSIZE customization was
done through a /etc/profile.d configuration snippet. The container will
almost certainly not share the vast majority of its /etc with the host,
because it will also almost certainly not share the vast majority of its
/usr with the host. Hence, the host's /etc/profile.d snippet will be
absent from the container.

This is observed by users of Toolbx containers, who expect to have the
same interactive command line user experience inside the container as on
the host. Toolbx can make the container share $HOME with the host, but
it can't expose an unknown /etc/profile.d snippet from the host.

One solution is to have Toolbx forward the value of the HISTSIZE
environment variable from the host to the container, so that the
customization done on the host is available in the container even if the
/etc/profile.d snippet isn't. For this to work, /etc/profile shouldn't
overwrite HISTSIZE if it's already set.

Note that Bash sets the default value of 500 only after reading all the
start-up scripts [1]. Hence, an integer comparison can't be done.

[1] https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html

https://github.com/containers/toolbox/issues/1359

rebased onto b49852e

5 months ago

rebased onto 80c2b94

5 months ago

Thank you for the ping and the fix for this problem with unfortunate consequences. Merging.

I am sorry for such delay it somehow slipped out of my radar.

Pull-Request has been merged by mosvald

3 months ago

Thank you for the ping and the fix for this problem with unfortunate consequences. Merging.

I am sorry for such delay it somehow slipped out of my radar.

No need to apologize. I miss notifications from issues and pull requests all the time. :)

Metadata