GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    mcc (mcc@mastodon.social)'s status on Monday, 01-Jul-2024 01:16:40 JST mcc mcc

    Is there a way to do `mv`, in either linux or Perl, that will fail if I try to copy a file over another file?

    In the mv manpage, I find a `-n` or `--no-clobber` option which does indeed refuse to replace file A with file B. But it is a silent failure. $? is 0 after I run an unsuccessful `mv -n`.

    In conversation about 11 months ago from mastodon.social permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Monday, 01-Jul-2024 03:57:17 JST mcc mcc
      in reply to
      • lj·rk
      • Matthew Miller

      @mattdm @ljrk

      In conversation about 11 months ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/112/706/918/568/230/307/original/11d80a8b2fc42625.png
      Paul Cantrell repeated this.
    • Embed this notice
      lj·rk (ljrk@todon.eu)'s status on Monday, 01-Jul-2024 03:57:17 JST lj·rk lj·rk
      in reply to
      • Matthew Miller

      @mcc @mattdm

      In conversation about 11 months ago permalink

      Attachments


      1. https://todon.eu/system/media_attachments/files/112/707/082/827/526/802/original/64fa3ed86c731c95.png
    • Embed this notice
      Matthew Miller (mattdm@hachyderm.io)'s status on Monday, 01-Jul-2024 03:57:18 JST Matthew Miller Matthew Miller
      in reply to
      • lj·rk

      @ljrk @mcc

      Anyway, everything is terrible.

      *switches to plan9*

      In conversation about 11 months ago permalink
    • Embed this notice
      Matthew Miller (mattdm@hachyderm.io)'s status on Monday, 01-Jul-2024 03:57:18 JST Matthew Miller Matthew Miller
      in reply to
      • lj·rk

      @ljrk @mcc

      Meanwhile on LWN... https://lwn.net/SubscriberLink/979524/f93c7f46307f3415/

      In conversation about 11 months ago permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: static.lwn.net
        Redox: An operating system in Rust [LWN.net]
    • Embed this notice
      Matthew Miller (mattdm@hachyderm.io)'s status on Monday, 01-Jul-2024 03:57:19 JST Matthew Miller Matthew Miller
      in reply to
      • lj·rk

      @ljrk @mcc

      Haven't tested, but I believe that's been fixed since 2015. From the release notes for 8.30 (2018):

      ``` 'mv -n A B' no longer suffers from a race condition that can
      overwrite a simultaneously-created B. This bug fix requires
      platform support for the renameat2 or renameatx_np syscalls, found
      in recent Linux and macOS kernels. As a side effect, 'mv -n A A'
      now silently does nothing if A exists.
      [bug introduced with coreutils-7.1]
      ```

      In conversation about 11 months ago permalink
    • Embed this notice
      Matthew Miller (mattdm@hachyderm.io)'s status on Monday, 01-Jul-2024 03:57:19 JST Matthew Miller Matthew Miller
      in reply to
      • lj·rk

      @ljrk @mcc

      Also this explains the `mv -n` silence when I tested on RHEL 7. :)

      In conversation about 11 months ago permalink
    • Embed this notice
      lj·rk (ljrk@todon.eu)'s status on Monday, 01-Jul-2024 03:57:20 JST lj·rk lj·rk
      in reply to
      • Matthew Miller

      @mattdm @mcc Unfortunately `-n` doesn't seem to be race-free though :/

      https://unix.stackexchange.com/questions/248544/mv-move-file-only-if-destination-does-not-exist/248547?noredirect=1#comment428238_248547

      With that in mind (if still true), I don't see any worth in a `-n` flag (invoking the "it's not UNIX" meme here :D). Then again, while there are many very bad options added by the GNU project if you ask me (GNU/tar's --checkpoint-action flag springs to mind), but this'd be a really useful flag in principle.

      In conversation about 11 months ago permalink
    • Embed this notice
      Matthew Miller (mattdm@hachyderm.io)'s status on Monday, 01-Jul-2024 03:57:21 JST Matthew Miller Matthew Miller
      in reply to

      @mcc

      IMHO good for the coreutils maintainers for making some of this stuff make more sense after all of these years.

      But I'll wait for the "they hate Unix!" crowd to show up.

      In conversation about 11 months ago permalink
    • Embed this notice
      Matthew Miller (mattdm@hachyderm.io)'s status on Monday, 01-Jul-2024 03:57:22 JST Matthew Miller Matthew Miller
      in reply to

      @mcc

      Update to (at least) coreutils 9.2, or use a distro which provides that.

      With that version, mv -n will print an error and return 1 if a file is skipped. (Previously, it just printed nothing to indicate it was doing nothing. Insert Drake meme here.)

      In conversation about 11 months ago permalink
    • Embed this notice
      Matthew Miller (mattdm@hachyderm.io)'s status on Monday, 01-Jul-2024 03:57:22 JST Matthew Miller Matthew Miller
      in reply to

      @mcc

      There is a new `--update none` option to get the old noclobber behavior, if you want it.

      tbh I'm surprised 1) they made what could be a breaking change and 2) to my knowledge there has been no "you broke my scripts" outcry. Although probably the second can be found if I look hard enough.

      Also, apparently posix only specifies -i and -f. Because, sure.

      In conversation about 11 months ago permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.