Results 1 to 4 of 4

Thread: what if commands created parent directories

  1. #1
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,819
    Distro
    Xubuntu 18.04 Bionic Beaver

    what if commands created parent directories

    what if it had been traditional for commands that would be trying to place a file object somewhere (such as the "mv" command) would, by default, create all the needed parent directories automatically just like mkdir does with the -p option? what kinds of problems could this cause?
    Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweeter

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: what if commands created parent directories

    You mean like
    • mkdir -p
    • rsync

    do? There's nothing to prevent anyone from creating a "smart-mv" command as a script.

  3. #3
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,819
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: what if commands created parent directories

    i already mentioned mkdir with the -p option. rsync does not create parent directories when you specify a target path that does not have a parent.
    Code:
    lt2a/forums /home/forums 6> ls -dl foo
    /bin/ls: cannot access 'foo': No such file or directory
    lt2a/forums /home/forums 7> ls -dl xv
    drwxr-xr-x 3 forums forums 4096 Jun 11  2020 xv
    lt2a/forums /home/forums 8> rsync -a xv foo/bar
    rsync: mkdir "/home/forums/foo/bar" failed: No such file or directory (2)
    rsync error: error in file IO (code 11) at main.c(675) [Receiver=3.1.2]
    lt2a/forums /home/forums 9>
    yes, i have created such a script. if the target exists and is not a directory, it does not replace it. and i also made a "smart-ln", too. in Python3, of course.
    Mask wearer, Social distancer, System Administrator, Programmer, Linux advocate, Command Line user, Ham radio operator (KA9WGN/8, tech), Photographer (hobby), occasional tweeter

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: what if commands created parent directories

    Ah, I've never seen rsync used like that.

    all I can see happening with that capability is a bunch of misspelled directories being created, unintentionally and people losing files even more than they do already.

    Imagine if this got implemented in a gui - ouch.

    https://stackoverflow.com/questions/...nt-directories ha a few options. Looks like cp --parents does it with a few restrictions on use. None are elegant to me for rsync.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •