Bug 55557

Summary: history -s ineffective in .bash_profile in for or case statement
Product: [Retired] Red Hat Linux Reporter: Rudolph T Maceyko <rtm>
Component: bashAssignee: Tim Waugh <twaugh>
Status: CLOSED CURRENTRELEASE QA Contact: Ben Levenson <benl>
Severity: low Docs Contact:
Priority: medium    
Version: 7.2CC: ralston
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-09-26 01:54:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rudolph T Maceyko 2001-11-01 22:01:21 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010809

Description of problem:
A construct such as this in .bash_profile should replace the last history
entry so that pressing c-p at the first prompt recalls the command "blah":

  if true; then
    history -s "blah"
    echo status=$?; history 1
  fi

Under bash-2.04-21 and prior versions (back to whichever version introduced
"history -s") this worked.  Starting with bash-2.05-8 it does not work.

Interestingly, if you change the expression so "history -s blah" is invoked
on its own, it *does* work, even with bash-2.05-8:

  history -s "blah"
  echo status=$?; history 1

Note again that the problem manifests itself in the dot files.  If you type
these commands interactively they will always succeed.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. mkdir tmphome
2. cat >>tmphome/.bash_profile<<END
if true; then
history -s "blah"
echo status=$?; history 1
fi
END
3. HOME=$PWD/tmphome bash --login
	

Actual Results:  bash-2.05$ mkdir tmphome
bash-2.05$ cat >>tmphome/.bash_profile<<END
> if true; then
> history -s "blah"
> echo status=$?; history 1
> fi
> END
bash-2.05$ HOME=$PWD/tmphome bash --login
status=0
bash-2.05$


Expected Results:  bash-2.04$ mkdir tmphome
bash-2.04$ cat >>tmphome/.bash_profile<<END
> if true; then
> history -s "blah"
> echo status=$?; history 1
> fi
> END
bash-2.04$ HOME=$PWD/tmphome bash --login
status=0
    1  blah
bash-2.04$



Additional info:

works:

  bash-2.04$ rpm -q bash redhat-release
  bash-2.04-21
  redhat-release-7.1-1

doesn't work:

  bash-2.05$ rpm -q bash redhat-release
  bash-2.05-8
  redhat-release-7.2-1

All errata are applied on both systems.

Comment 1 Tim Waugh 2002-10-11 11:05:21 UTC
This seems to be fixed in Red Hat Linux 8.0.