Bug 1112653 - Bash's system-wide startup file for interactive shells overwrites history control variables
Bash's system-wide startup file for interactive shells overwrites history con...
Status: RESOLVED FIXED
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem
Current
x86-64 openSUSE Factory
: P5 - None : Minor (vote)
: ---
Assigned To: Ruediger Oertel
E-mail List
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-10-21 20:52 UTC by Tim Friske
Modified: 2018-12-10 13:30 UTC (History)
2 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Friske 2018-10-21 20:52:26 UTC
In the latest version of _openSUSE Tumbleweed_ the file `/etc/bash.bashrc` wrongly overwrites the following of Bash's variables for history control:

.`HISTTIMEFORMAT` respects already set `HISTTIMEFORMAT` but with unsafe variable assignment
----
# All commands of root will have a time stamp
if test "$UID" -eq 0  ; then
    HISTTIMEFORMAT=${HISTTIMEFORMAT:-"%F %H:%M:%S "}
fi
----

.`HISTCONTROL` does *not* respect already set `HISTCONTROL`
----
# Do not save dupes and lines starting by space in the bash history file
HISTCONTROL=ignoreboth
----

In my opinion the code should look like this:

.`HISTTIMEFORMAT` respects already set `HISTTIMEFORMAT`
----
# All commands of root will have a time stamp
if test "$UID" -eq 0  ; then
    HISTTIMEFORMAT="${HISTTIMEFORMAT:-%F %H:%M:%S }"
fi
----

.`HISTCONTROL` respects already set `HISTCONTROL`
----
# Do not save dupes and lines starting by space in the bash history file
HISTCONTROL="${HISTCONTROL:-ignoreboth}"
----
Comment 1 Ruediger Oertel 2018-10-26 12:06:17 UTC
werner, this seems to be a change you did in 2011, can you have a look ?
Comment 2 Dr. Werner Fink 2018-11-09 08:06:19 UTC
The lines may look like

 # All commands of root will have a time stamp
 if test "$UID" -eq 0  ; then
     : ${HISTTIMEFORMAT:="%F %H:%M:%S "}
 fi

and

 : ${HISTCONTROL:=ignoreboth}

as this will not overwrite already set and none-empty variables

@Tim ... does this work for you?
Comment 3 Tim Friske 2018-11-13 20:21:14 UTC
Hi Werner,

similar to the other default settings in Bash's system-wide startup file `/etc/bash.bashrc` such as `: ${VISUAL=emacs}` I would rather prefer to have it assign a default value to a variable only iff it is unset, i.e. *not*, if a variable is set but set to `null`. In this case:

.Choose default values for unset variables only
----
# I would rather prefer (assignment operator =, not :=):
#
: ${HISTTIMEFORMAT="%F %H:%M:%S "}
: ${HISTCONTROL=ignoreboth}
#
# as opposed to:
#
: ${HISTTIMEFORMAT:="%F %H:%M:%S "}
: ${HISTCONTROL:=ignoreboth}
----
Comment 4 Dr. Werner Fink 2018-12-10 12:55:27 UTC
SR#656833
Comment 5 Swamp Workflow Management 2018-12-10 13:30:06 UTC
This is an autogenerated message for OBS integration:
This bug (1112653) was mentioned in
https://build.opensuse.org/request/show/656833 Factory / aaa_base