Bug 144331 - mkinitrd fails with noclobber set in shell
Summary: mkinitrd fails with noclobber set in shell
Alias: None
Product: Fedora
Classification: Fedora
Component: mkinitrd   
(Show other bugs)
Version: 3
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Peter Jones
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2005-01-06 02:02 UTC by Joshua Buysse
Modified: 2007-11-30 22:10 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-03-23 22:22:59 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to mkinitrd that does 'set +o noclobber' (332 bytes, patch)
2005-03-07 22:55 UTC, Joshua Buysse
no flags Details | Diff

Description Joshua Buysse 2005-01-06 02:02:42 UTC
Description of problem:

The mkinitrd command fails to create a new image if noclobber is set
in the shell.

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

How reproducible: 
  Every time.

Steps to Reproduce:
1. set -o noclobber
2. mkinitrd $version.img $version
Actual results:
  /sbin/mkinitrd: line 776: /tmp/initrd.img.xv5505: cannot overwrite
existing file.

  No image created.

Expected results:
  No output, rd image created.

Additional info:
  Same problem as bug 144053 (groff, man fails if noclobber set).

Comment 1 Peter Jones 2005-03-07 22:46:17 UTC
I'll happily take a patch to fix this.  Unless somebody provides one, I don't
think it's worth the trouble to fix.

Comment 2 Joshua Buysse 2005-03-07 22:55:44 UTC
Created attachment 111759 [details]
Patch to mkinitrd that does 'set +o noclobber'

Comment 3 Chris Dukes 2005-03-08 17:58:38 UTC
Your patch fixes the symptoms without neccesarily fixing the root cause of the
1) Are you really doing 'set -o noclobber' from the shell, or are you doing it
from $BASH_ENV or something called by $BASH_ENV?  If so, you can reasonably
expect to clobber any /bin/bash script.
2) Is bash inheriting 'set -o noclobber'?

Try this test script
cat > /tmp/ts <<EEOOFF
#!/bin/bash -x
\echo BASH_ENV="'$BASH_ENV'"
\set -o | /bin/grep clobber
Try running 'set -o noclobber;/tmp/ts' and 'set +o noclobber;/tmp/ts'.
If the script is inheriting the setting, double check to see if this is current
correct behavior.  If not, open the bug against 'bash'.
If 'set -o noclobber' is being set by $BASH_ENV you should consider one of the
1) Use ~/.bashrc for interactive shells.
2) Use a case $- in; *i*) .... ;; esac construct to only set noclobber for
interactive shells
3) Accept that your choice of $BASH_ENV over ~/.bashrc is going to skew behavior
 of bash scripts.

Red Hat,
I strongly recommend that you audit your #!/bin/bash scripts to see if they run
correctly with the 'dash' posix shell.  If so, change #!/bin/bash to #!/bin/sh t
his will remove the possibility of $BASH_ENV overriding default behavior. If
bashisms are present, re-evaluate whether or not they are appropriate to the task.

Comment 4 Peter Jones 2005-03-23 22:22:59 UTC
Fixed in rawhide.

Note You need to log in before you can comment on or make changes to this bug.