[Toybox] [PATCH] Implement mv -n / cp -n (no clobber).
Andy Chu
andychup at gmail.com
Sun Mar 27 12:09:44 PDT 2016
>> Anecdotally, it seems like a lot of shell script issues are caused by
>> unexpected existing state, but in a lot of cases you don't CARE about
>> the existing state -- you just want a final state (e.g. a bunch of
>> symlinks to toybox).
>
> "ln -sf" actually works pretty predictably. :)
One more nitpick ... ln -sf isn't idempotent for the same reason that
cp isn't. If you run it more than once you get different results.
I was trying to create a package manager with sandboxed builds, with
the aforementioned linux-user-chroot, and my own tools. Bootstrapped
all in shell. All of my ln invocations used -T /
--no-target-directory for this reason. (At least this flag doesn't
seem to be entangled with other behavior, unlike mkdir and rm).
$ mkdir foo
$ ln -sf foo link; tree --charset=ascii
.
|-- foo
`-- link -> foo
$ ln -sf foo link; tree --charset=ascii
.
|-- foo
| `-- foo -> foo
`-- link -> foo
Compare with:
$ mkdir foo
$ ln -sf -T foo link; tree --charset=ascii
.
|-- foo
`-- link -> foo
$ ln -sf -T foo link; tree --charset=ascii
.
|-- foo
`-- link -> foo
Andy
Andy
1459105784.0
More information about the Toybox
mailing list