sed -i symlink behavior...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I just noticed some behavior changes within sed. Run the following commands in various distros.

#!/bin/bash
set -x
echo "abc" > original.txt
ln -s original.txt symlink.txt
sed -i 's/abc/123/' symlink.txt
if [ -L symlink.txt ]; then
    echo yes symlink
else
    echo not symlink anymore
fi
cat original.txt
cat symlink.txt

RHEL5
=====
[user@rhel5 ~]$ echo "abc" > original.txt
[user@rhel5 ~]$ ln -s original.txt symlink.txt
[user@rhel5 ~]$ sed -i 's/abc/123/' symlink.txt
sed: ck_follow_symlink: couldn't lstat s/original.txt: No such file or directory
[user@rhel5 ~]$ cat symlink.txt
abc
[user@rhel5 ~]$ cat original.txt
abc

original.txt is unmodified, symlink.txt is still a symlink.

Fedora 10
=========
[user@fedora10 ~]$ echo "abc" > original.txt
[user@fedora10 ~]$ ln -s original.txt symlink.txt
[user@fedora10 ~]$ sed -i 's/abc/123/' symlink.txt
[user@fedora10 ~]$ cat symlink.txt
123
[user@fedora10 ~]$ cat original.txt
123

original.txt is modified, symlink.txt is still a symlink.

Fedora 11 and 12
================
[user@fedora11 ~]$ echo "abc" > original.txt
[user@newcaprica ~]$ ln -s original.txt symlink.txt
[user@newcaprica ~]$ sed -i 's/abc/123/' symlink.txt
[user@newcaprica ~]$ cat original.txt
abc
[user@newcaprica ~]$ cat symlink.txt
123

original.txt is not modified, symlink.txt is no longer a symlink. symlink.txt now contains a modified version of original.txt as a plain file.

What is the correct behavior?  Is this a bug that it changed?

Warren Togami
wtogami@xxxxxxxxxx

--
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux