From unknown Sat Aug 16 21:59:50 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#49287 <49287@debbugs.gnu.org> To: bug#49287 <49287@debbugs.gnu.org> Subject: Status: sed -i disrespects read-only Reply-To: bug#49287 <49287@debbugs.gnu.org> Date: Sun, 17 Aug 2025 04:59:50 +0000 retitle 49287 sed -i disrespects read-only reassign 49287 sed submitter 49287 Leonid Mironov severity 49287 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 30 04:30:42 2021 Received: (at submit) by debbugs.gnu.org; 30 Jun 2021 08:30:42 +0000 Received: from localhost ([127.0.0.1]:56414 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyVcH-0006RI-OC for submit@debbugs.gnu.org; Wed, 30 Jun 2021 04:30:42 -0400 Received: from lists.gnu.org ([209.51.188.17]:33994) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyTHi-0002pt-QF for submit@debbugs.gnu.org; Wed, 30 Jun 2021 02:01:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyTHi-00020P-Gh for bug-sed@gnu.org; Wed, 30 Jun 2021 02:01:18 -0400 Received: from mout.gmx.com ([74.208.4.200]:35909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyTHf-00070q-Ql for bug-sed@gnu.org; Wed, 30 Jun 2021 02:01:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.com; s=dbd5af2cbaf7; t=1625032873; bh=JdLEuQI51631LEUR8Ojumr1G7fcalvXN4lUUL54nUb8=; h=X-UI-Sender-Class:From:To:Subject:Date; b=P2omq0meHR+O3Iv5RgiXkzngx1/APr+TY7SiH2fKEfOALfRW39fYVlCqHIW+YEnsA Fulb9lAzRorMWIWyDdz30ap1FWFrfJ89RcKTbuYSgVCa7UT65Tig84IFye2GbwmZuP WS9dYbIBD8dIh41iRM5ywEuoRmkgsAJynlvPrV60= X-UI-Sender-Class: 214d933f-fd2f-45c7-a636-f5d79ae31a79 Received: from [188.32.94.24] ([188.32.94.24]) by web-mail.mail.com (3c-app-mailcom-lxa06.server.lan [10.76.45.7]) (via HTTP); Wed, 30 Jun 2021 08:01:13 +0200 MIME-Version: 1.0 Message-ID: From: Leonid Mironov To: bug-sed@gnu.org Subject: sed -i disrespects read-only Content-Type: text/html; charset=UTF-8 Date: Wed, 30 Jun 2021 08:01:13 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:ozawPwHeyPr+r6DXAFmzUuLgOd+lR3oC9oHnJ0yBtbug4dww3+CtWlG+agwYfGkx+RCTn Arlnp4DgM9BZk7749Zu5V61SkrxqSwvXWXVk8GlOAJuXkjgrcsob0b8MFLGM0T6xg9n1AmQIzYGb GTqBerBzZrAjRWV9YuHN1SA/WI0WQRjNPAXhdHr5kz2ojWxZjjkASUi0MDXZvZ+UkcAwzh0d9WkM AkuI4BKlwQwLy5row5utvo3wZPm9jT3MaTHcU1vCo7vzsjWIdKNlB2U/rpJCG10BvRSM71/qsBBD cM= X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:t5oNOO/IfsQ=:coJ7UiI6CwTGHw2HLR5f/0 IOG7tMG+3+HIaqx33I/k0VV/lcgf2TnQ3ZxRdzyLClePVU/zbnhXBVMB9Jg3BQ84aYGRSpzEd ZLKSXwVrwlMDV+u/XDcBpd+1SUejRkG0vQF9HrpsMC1mlcpzVWpdeDhRkhpyv2VBd7edNNwwM KOp1xU53N2OFAe55gG1uyfbI6kDZcGqkqF+wmmvkaIVPc/20OZzr5JrL6bhbpm/JLKrnV5+bV euvnlf3kHhhBd4AbWoLuG5YQEQvMRZINHOWOIhutDsmeX2c//5PIZBXXMI= Received-SPF: pass client-ip=74.208.4.200; envelope-from=lvm@royal.net; helo=mout.gmx.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, MIME_HTML_ONLY=0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.6 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 30 Jun 2021 04:30:40 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--)
Hello,
 
sed disrespects read-only file attributes when editing in place.
 
$ ls -l testfile*
-r--r--r-- 1 lvm lvm 50 Jun 30 08:32 testfile
$ sed 's/test/bug/g' -i~ testfile
$ diff testfile testfile~
2c2
< this is a bug
---
> this is a test
$ sed --version
sed (GNU sed) 4.4
Copyright © 2017 Free Software Foundation, Inc.
Licence GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.
$ uname -a
Linux server 5.4.0-74-generic #83~18.04.1-Ubuntu SMP Tue May 11 16:01:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
 
 
Not the latest version, but buiding latest git sources fails with
 
  CC       sed/sed_sed-execute.o
sed/execute.c: In function 'open_next_file':
sed/execute.c:575:7: error: unknown type name 'security_context_t'; did you mean 'security_class_t'?
       security_context_t old_fscreatecon;
       ^~~~~~~~~~~~~~~~~~
       security_class_t
sed/execute.c:596:11: error: unknown type name 'security_context_t'; did you mean 'security_class_t'?
           security_context_t con;
           ^~~~~~~~~~~~~~~~~~
           security_class_t
sed/execute.c:597:49: error: passing argument 2 of 'lgetfilecon' from incompatible pointer type [-Werror=incompatible-pointer-types]
           if (lgetfilecon (input->in_file_name, &con) != -1)
                                                 ^
In file included from sed/execute.c:33:0:
./lib/selinux/selinux.h:104:1: note: expected 'char **' but argument is of type 'int *'
 lgetfilecon (char const *file _GL_UNUSED_PARAMETER,
 ^~~~~~~~~~~
sed/execute.c:601:51: error: passing argument 1 of 'getfscreatecon' from incompatible pointer type [-Werror=incompatible-pointer-types]
               reset_fscreatecon = getfscreatecon (&old_fscreatecon) >= 0;
                                                   ^
In file included from sed/execute.c:33:0:
./lib/selinux/selinux.h:89:1: note: expected 'char **' but argument is of type 'int *'
 getfscreatecon (char **con _GL_UNUSED_PARAMETER)
 ^~~~~~~~~~~~~~
sed/execute.c:602:35: error: passing argument 1 of 'setfscreatecon' makes pointer from integer without a cast [-Werror=int-conversion]
               if (setfscreatecon (con) < 0)
                                   ^~~
In file included from sed/execute.c:33:0:
./lib/selinux/selinux.h:92:1: note: expected 'const char *' but argument is of type 'int'
 setfscreatecon (char const *con _GL_UNUSED_PARAMETER)
 ^~~~~~~~~~~~~~
In file included from ./lib/gettext.h:26:0,
                 from ./basicdefs.h:26,
                 from sed/sed.h:18,
                 from sed/execute.c:20:
sed/execute.c:603:36: error: format '%s' expects argument of type 'char *', but argument 4 has type 'int' [-Werror=format=]
                 fprintf (stderr, _("%s: warning: failed to set default" \
                                    ^
sed/execute.c:603:34: note: in expansion of macro '_'
                 fprintf (stderr, _("%s: warning: failed to set default" \
                                  ^
sed/execute.c:604:64: note: format string is defined here
                                    " file creation context to %s: %s"),
                                                               ~^
                                                               %d
sed/execute.c:606:24: error: passing argument 1 of 'freecon' makes pointer from integer without a cast [-Werror=int-conversion]
               freecon (con);
                        ^~~
In file included from sed/execute.c:33:0:
./lib/selinux/selinux.h:86:1: note: expected 'char *' but argument is of type 'int'
 freecon (char *con _GL_UNUSED_PARAMETER) {}
 ^~~~~~~
sed/execute.c:625:27: error: passing argument 1 of 'setfscreatecon' makes pointer from integer without a cast [-Werror=int-conversion]
           setfscreatecon (old_fscreatecon);
                           ^~~~~~~~~~~~~~~
In file included from sed/execute.c:33:0:
./lib/selinux/selinux.h:92:1: note: expected 'const char *' but argument is of type 'int'
 setfscreatecon (char const *con _GL_UNUSED_PARAMETER)
 ^~~~~~~~~~~~~~
sed/execute.c:626:20: error: passing argument 1 of 'freecon' makes pointer from integer without a cast [-Werror=int-conversion]
           freecon (old_fscreatecon);
                    ^~~~~~~~~~~~~~~
In file included from sed/execute.c:33:0:
./lib/selinux/selinux.h:86:1: note: expected 'char *' but argument is of type 'int'
 freecon (char *con _GL_UNUSED_PARAMETER) {}
 ^~~~~~~
cc1: all warnings being treated as errors
Makefile:2913: recipe for target 'sed/sed_sed-execute.o' failed
make[2]: *** [sed/sed_sed-execute.o] Error 1
make[2]: Leaving directory '/tmp/2/sed'
Makefile:3193: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/2/sed'
Makefile:2375: recipe for target 'all' failed
make: *** [all] Error 2
 
 
From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 01 09:22:16 2021 Received: (at submit) by debbugs.gnu.org; 1 Jul 2021 13:22:16 +0000 Received: from localhost ([127.0.0.1]:59944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lywe0-0001Hf-A8 for submit@debbugs.gnu.org; Thu, 01 Jul 2021 09:22:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:40616) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lywdy-0001HY-Fz for submit@debbugs.gnu.org; Thu, 01 Jul 2021 09:22:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lywdy-0000C2-9q for bug-sed@gnu.org; Thu, 01 Jul 2021 09:22:14 -0400 Received: from mout.gmx.net ([212.227.17.20]:59391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lywdw-0002lU-FS for bug-sed@gnu.org; Thu, 01 Jul 2021 09:22:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1625145729; bh=NUPA4L1WaIOQWIsN2poqIR3T+Ea4onGlnrz/nqs0EB4=; h=X-UI-Sender-Class:Date:From:To:Subject:In-Reply-To:References; b=lgRPSKyUUkLdPp9SPnSrsZDmGoJDYcnzYbxn9fpk0VsQT0cOXLyMaPDddVVUfAlQw jDfar13zJxupOG2xrysiCsdkU6sK9Sh583m+EeAccHgTIe8gC95qmCvICvWzyLo69w NfLloH7vdbBJgRMOGyL78Jj5JnRxETn1QojlwAeU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from gonzo ([80.104.225.143]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MQeA2-1lcLrD05gM-00NinQ for ; Thu, 01 Jul 2021 15:22:09 +0200 Date: Thu, 1 Jul 2021 15:22:07 +0200 From: Davide Brini To: bug-sed@gnu.org Subject: Re: bug#49287: sed -i disrespects read-only Message-ID: <20210701152207.71734d1e@gonzo> In-Reply-To: References: X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:/ZBr9QWW19lu6O3Xe9ySL/lapDutVxuAzKOPw0kYQiBJiY44SiS BOhYah9mqnEqpcXG7T1RmwLP7tMdKZlPz3iWKXaWxBpd9vre6PPnK3Y8b2wmjFchvwd4sMk E7636NuOagxEWWvIwwa/sv+6cIwCPOLosdyDeDAxzy/pv2kZcBvEuRw2eMC1LXXuN0slCTO xivpek3cYeE8W0NNHpdmQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:XCFnXPyv6tg=:c7iRSUDtEYK4FtVF6a8Xdo TllVfwpsVX69ZqGnx9mSw5kFc9S/tEBPUGvcUfescvNUY+ZsfcQoxVWOrYYyyDbvVk7KyPT5B Ev+Ef/gZrvGDmXAJPC2yUbGXJHmDhNDaNSiUlZE57vrkkRNxwt9ZsJEIW1LbK4er9G3RNx3IV e6u256g8133o9pSqtzvcMr0VWIBdXXgSFrKt1oLYQWrF9jhEQb/T/527fWdm9hb3XvSOcTufz Ge23beHQFR95fC898QLbZgmakBLLZA3dF3hLjqfxuGVgn7GJIAmg5soc5TRoRnq3BC622h5Qx eEdkojrU+13cUPipNHu0aS8KeLldp2Nr2y7Tx6f1t6EWgytQ5MqHhsOHzy6MpJxI55ZQ3SjwY W3rYSjPD2M1vTHK+ALWiTSAF4T1LKgqkhIS/kt5EwbDrut3YIw2HxdPWTO+CM9xOhedrQn5Jw cJdksa6c5tNtfzKaVvcMDwbhQW7WQPs5T4prrZLAyznMvb7g+zIrpNOJF8VT6dXiJ0ZXL3gbd nXI+BoCFp4blDzw5/MieGggslnS+NNP7qQ7sp/YF+MPI4hAzAe9YUx1hbn9roqHglbk80xRk1 5L7pPuvNHBIHMWf1d50qgtTmJsva+zjy07eMC0gvB+4jlI3G+LadV0r7zYMDiJT0LwQ4x02mN y/9oLQ8U8YXx+VP/iXA2KFkd8Ua0cPLhrtXk4kPHm5+u0hDvVyX7L/jksUafki7/7eNRyYbLa S+k1b3vbQMSyDBgpKOd6F5C3994pMnX/+RZbCCvDMYtdNv1wEhncgW90ifwNLU2Y+3/OZzDFe qU+urzt02vfNf9lIwM+quj/C2/9DCAmpU7AgA+6M9lH5Fyw/kZ1C+h/VVEdcn9JczWyvG+8jW NpvR5JRxJKd4+crqHLsG9dYfcZSqSMN8Jj42qpMHbVcZWwGEUC2eveEv5owNc5P2UXVkZgBhq v3QaNZBy33SXtjO0CpftwHYgoUG6jQ42j8SFrRA2M+1XuGGVQVM1C1uk2Cp2CtcnrV90yPowA xzR9a0yFsz6rKxxsaobGg7qr1opm+8Ht6NBm6zt8KBy8c/MQFxSmAASnkQ+samiEsazngOBbz fvwcWv057k2lZjP2gJcwMLV8FP9YlAWO5yd Received-SPF: pass client-ip=212.227.17.20; envelope-from=dave_br@gmx.com; helo=mout.gmx.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) On Wed, 30 Jun 2021 08:01:13 +0200, Leonid Mironov wrote: > Hello, > > sed disrespects read-only file attributes when editing in place. > > $ ls -l testfile* > -r--r--r-- 1 lvm lvm 50 Jun 30 08:32 testfile > $ sed 's/test/bug/g' -i~ testfile > $ diff testfile testfile~ > 2c2 > < this is a bug > --- > > this is a test > $ sed --version > sed (GNU sed) 4.4 Well tecnically this is correct since sed never writes to the original file, instead it creates a new file, writes to it and finally renames it to the old name, so the original file permissions never come into play (in case you're wondering: it's not really "in-place"). I agree it could be surprising, but once you know how it works behind the scenes it should make a bit more sense. =2D- D. From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 04 17:18:03 2021 Received: (at 49287) by debbugs.gnu.org; 4 Aug 2021 21:18:03 +0000 Received: from localhost ([127.0.0.1]:45286 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBOH5-0002Od-E6 for submit@debbugs.gnu.org; Wed, 04 Aug 2021 17:18:03 -0400 Received: from mail-pj1-f49.google.com ([209.85.216.49]:44761) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBOH0-0002O6-Mn for 49287@debbugs.gnu.org; Wed, 04 Aug 2021 17:18:02 -0400 Received: by mail-pj1-f49.google.com with SMTP id e2-20020a17090a4a02b029016f3020d867so5441641pjh.3 for <49287@debbugs.gnu.org>; Wed, 04 Aug 2021 14:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=KK7vXznfAiy9qV+7wcETQ6XFmiSEDrE20dvWA4p9GwE=; b=aqjOs8zZcDHVfBo30m4sTFtkm2AQpEdlZtIYDMNVUGu9Y6dV17Yg7B9CVEqe0CMVM8 5brXtHWRd8+UsFUGRlDjUJgmtolQlWrN1+AZwi8pme9xqPZT1KRQvEk7/MtKhT7y5NV+ 6BYY0QWAfR6QyDkI3yAiuxTsVh11KxGm1hZt3C3YuXbd2YdNPDkIz7QShpdE+UZOrgrI wKNEFZ1xjRaWzKlGmwFpqrNlyDDrAZ6IoO7NWDrvZ5/Ryk9+qy6Phn1FM2yQoS4QV/Sz qv5tBZoUrVOKZhz8Y8mMB25func5+5kFNYiAJHiSLjcvkvQqp1AIxzsUIwR4p27MTd0N 1x/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KK7vXznfAiy9qV+7wcETQ6XFmiSEDrE20dvWA4p9GwE=; b=JixyaluTgOQaMd2UVxeTz2dx8QeDOosHOKUWusVw/Ke5i5SluO5dXxnd9X5P8u97id zP12FxoZCfPQNGORp8TtzOUaVnTpYddQNqjELCcO+Vl59AETKzgAqBWQttu9KUkzKt7U zpPEOFtgOdOEmeCHypr4daL3nl0WeMQ+mPC7SmXNnh/y9f0fjreCv7MxJVSHoFuUCAbD 4/Gu0R+gGurr4XX25C9NbvAgerJsdWzLsKxxmginuALFWIejmebIUlji7pJNQqTjjPM0 YWj8ePYgG3jmJsjzs/kv/SQaL+dLxSZv0qKUndnCdy+toIJHgFETqG2GB/gNVGDh2pdV 5MZw== X-Gm-Message-State: AOAM533Y9uIQgBfho48y6YSw/gcSBPtOcFOby1+JtCP3XvTHbvt6xKLs E4l0sbwYJP779loYMvPW6WI= X-Google-Smtp-Source: ABdhPJzcDpS+75LEqTA3HuCwOAS8hawWoZ9VJPEXjNE9CXEBXNnIle/kWwNucNNr/4l7Ktn0iaTKdw== X-Received: by 2002:a63:155f:: with SMTP id 31mr745176pgv.167.1628111872471; Wed, 04 Aug 2021 14:17:52 -0700 (PDT) Received: from tomato.moose.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id kr6sm7174680pjb.23.2021.08.04.14.17.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Aug 2021 14:17:51 -0700 (PDT) Subject: Re: bug#49287: sed -i disrespects read-only To: Davide Brini , 49287@debbugs.gnu.org, Leonid Mironov References: <20210701152207.71734d1e@gonzo> From: Assaf Gordon Message-ID: <51fde17c-5b8c-6bef-939d-387ddf458569@gmail.com> Date: Wed, 4 Aug 2021 15:17:50 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210701152207.71734d1e@gonzo> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -0.1 (/) X-Debbugs-Envelope-To: 49287 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) tag 49287 notabug close 49287 stop Hello, On 2021-07-01 7:22 a.m., Davide Brini wrote: > On Wed, 30 Jun 2021 08:01:13 +0200, Leonid Mironov wrote: > >> sed disrespects read-only file attributes when editing in place. >> > > Well tecnically this is correct since sed never writes to the > original file, instead it creates a new file, writes to it and finally > renames it to the old name, so the original file permissions never come > into play (in case you're wondering: it's not really "in-place"). > > I agree it could be surprising, but once you know how it works behind > the scenes it should make a bit more sense. > Thank you Davide for answering. I would like to emphasize that this should *not* be surprising, as it the way UNIX file and directory permissions have always worked - this has nothing to do with sed. Please see similar (and more detailed) discussion about it here: https://lists.gnu.org/archive/html/bug-sed/2017-06/msg00000.html Please see here for in-depth examples of how "in-place" is not so trivial: http://www.pixelbeat.org/docs/unix_file_replacement.html regards, -assaf