Don't use -e to test for what might be broken symlink
The behavior of test -e and [[ -e against broken symlinks is to fail even if the symlink exists. However we want to test if the link exists or if there is a file in that location. Therefore switch from test -e to test -L and test -f to check if the file or link exists regardless of link target validity. Change-Id: I84a9b6731eccf950707be50aef464a2de1e33e8e
This commit is contained in:
parent
40ec3fc92d
commit
f3d58d9042
@ -342,7 +342,9 @@ function create_base () {
|
||||
# Save resolv.conf as created by the initial install. Note the
|
||||
# .ORIG file is an exported interface -- it may be modified and we
|
||||
# will copy it back in during finalisation of the image.
|
||||
if [[ -e $TMP_MOUNT_PATH/etc/resolv.conf ]]; then
|
||||
# Note that we use -L and -f to test here as test (and bash [[)
|
||||
# return false with -e if the link target does not exist.
|
||||
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf ] ; then
|
||||
sudo mv $TMP_MOUNT_PATH/etc/resolv.conf $TMP_MOUNT_PATH/etc/resolv.conf.ORIG
|
||||
fi
|
||||
|
||||
|
@ -116,7 +116,9 @@ function finalise_base () {
|
||||
# Remove the resolv.conf we created and put the original (or
|
||||
# perhaps modified) version back.
|
||||
sudo rm -f $TMP_MOUNT_PATH/etc/resolv.conf
|
||||
if [ -e $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ]; then
|
||||
# Note that we use -L and -f to test here as test (and bash [[)
|
||||
# return false with -e if the link target does not exist.
|
||||
if [ -L $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] || [ -f $TMP_MOUNT_PATH/etc/resolv.conf.ORIG ] ; then
|
||||
sudo mv $TMP_MOUNT_PATH/etc/resolv.conf.ORIG $TMP_MOUNT_PATH/etc/resolv.conf
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user