Bug 144331 - mkinitrd fails with noclobber set in shell
mkinitrd fails with noclobber set in shell
Product: Fedora
Classification: Fedora
Component: mkinitrd (Show other bugs)
All Linux
medium Severity high
: ---
: ---
Assigned To: Peter Jones
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2005-01-05 21:02 EST by Joshua Buysse
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-03-23 17:22:59 EST
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 17:55 EST, Joshua Buysse
no flags Details | Diff

  None (edit)
Description Joshua Buysse 2005-01-05 21:02:42 EST
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 17:46:17 EST
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 17:55:44 EST
Created attachment 111759 [details]
Patch to mkinitrd that does 'set +o noclobber'
Comment 3 Chris Dukes 2005-03-08 12:58:38 EST
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 17:22:59 EST
Fixed in rawhide.

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