Red Hat Bugzilla – Bug 144331
mkinitrd fails with noclobber set in shell
Last modified: 2007-11-30 17:10:57 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
Steps to Reproduce:
1. set -o noclobber
2. mkinitrd $version.img $version
/sbin/mkinitrd: line 776: /tmp/initrd.img.xv5505: cannot overwrite
No image created.
No output, rd image created.
Same problem as bug 144053 (groff, man fails if noclobber set).
I'll happily take a patch to fix this. Unless somebody provides one, I don't
think it's worth the trouble to fix.
Created attachment 111759 [details]
Patch to mkinitrd that does 'set +o noclobber'
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
\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
3) Accept that your choice of $BASH_ENV over ~/.bashrc is going to skew behavior
of bash scripts.
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.
Fixed in rawhide.