These files may or may not exist; check to see if they exist before copying them! --- dracut/anaconda-copy-cmdline.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dracut/anaconda-copy-cmdline.sh b/dracut/anaconda-copy-cmdline.sh index 26aa340..2731d6c 100755 --- a/dracut/anaconda-copy-cmdline.sh +++ b/dracut/anaconda-copy-cmdline.sh @@ -1,5 +1,7 @@ #!/bin/sh # Copy over cmdline(.d) files from the initrd to /run before pivot mkdir -p /run/install/cmdline.d -cp /etc/cmdline.d/* /run/install/cmdline.d/ -cp /etc/cmdline /run/install/ +for f in /etc/cmdline.d/*; do + [ -e $f ] && cp $f /run/install/cmdline.d/ +done +[ -e /etc/cmdline ] && cp /etc/cmdline /run/install/
On Thu, Feb 28, 2013 at 11:44:46AM -0500, Will Woods wrote:
These files may or may not exist; check to see if they exist before copying them!
dracut/anaconda-copy-cmdline.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dracut/anaconda-copy-cmdline.sh b/dracut/anaconda-copy-cmdline.sh index 26aa340..2731d6c 100755 --- a/dracut/anaconda-copy-cmdline.sh +++ b/dracut/anaconda-copy-cmdline.sh @@ -1,5 +1,7 @@ #!/bin/sh # Copy over cmdline(.d) files from the initrd to /run before pivot mkdir -p /run/install/cmdline.d -cp /etc/cmdline.d/* /run/install/cmdline.d/ -cp /etc/cmdline /run/install/ +for f in /etc/cmdline.d/*; do
- [ -e $f ] && cp $f /run/install/cmdline.d/
You don't really need that -e there since it's iterating over what's in the directory.
+done
+[ -e /etc/cmdline ] && cp /etc/cmdline /run/install/
1.8.1.2
Ack otherwise.
On Thu, 2013-02-28 at 10:35 -0800, Brian C. Lane wrote:
On Thu, Feb 28, 2013 at 11:44:46AM -0500, Will Woods wrote:
These files may or may not exist; check to see if they exist before copying them!
dracut/anaconda-copy-cmdline.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dracut/anaconda-copy-cmdline.sh b/dracut/anaconda-copy-cmdline.sh index 26aa340..2731d6c 100755 --- a/dracut/anaconda-copy-cmdline.sh +++ b/dracut/anaconda-copy-cmdline.sh @@ -1,5 +1,7 @@ #!/bin/sh # Copy over cmdline(.d) files from the initrd to /run before pivot mkdir -p /run/install/cmdline.d -cp /etc/cmdline.d/* /run/install/cmdline.d/ -cp /etc/cmdline /run/install/ +for f in /etc/cmdline.d/*; do
- [ -e $f ] && cp $f /run/install/cmdline.d/
You don't really need that -e there since it's iterating over what's in the directory.
Actually, you do!
If the directory is empty or not present, bash will expand "/etc/cmdline.d/*" to "/etc/cmdline.d/*". Attempting to copy that file will result in the error message we're trying to avoid, because it doesn't exist.
So this is a common shell idiom to avoid that error message:
for f in /some/path/glob*; do [ -e $f ] || break # nothing matched the glob ... # otherwise, do stuff with the files done
The code above is just a variation on that.
-w (who knows way more about shell than he would like)
anaconda-patches@lists.fedorahosted.org