On Sun, Aug 20, 2017 at 4:57 PM, Philip Hands <p...@hands.com> wrote:
> Ben Hildred <426...@gmail.com> writes:
>
>> On Sun, Aug 20, 2017 at 3:25 AM, Ansgar Burchardt <ans...@debian.org> wrote:
>>
>>> Dan Nicholson writes:
>>> > On Fri, Aug 18, 2017 at 2:48 PM, Henrique de Moraes Holschuh
>>> > <h...@debian.org> wrote:
>>> >> Wouldn't it be more straigthforward to "test -e || mknod" ?
>>> >
>>> > I definitely considered that, but it seemed more noisy to the code to
>>> > add a conditional for every call. But I'd be fine reworking to that
>>> > approach if that's more acceptable, though.
>>>
>>> You can always introduce a `mknod_if_not_exists` function or so.  Though
>>> I'm not sure this is worth here (the name is so long the `test -e` is
>>> almost shorter).
>>>
>>> Ansgar
>>>
>>>
>> function mknod-e () {
>>     [ -e "$1" ] || mknod "$@"
>> }
>
> $1 for mknod in this case is liable to be '-m'
>
> The attached patch might satisfy the quest for neatness.
>
> One could instead call the function something like
> ensure-exists-in-target and leave the /dev/'s on all the filenames, if
> that were considered clearer.

That certainly helps, but it doesn't cover everything since the
mkdir's and ln's could fail. Those are easier to handle by adding -p
and -f, respectively, but that's a subtle change in behavior for ln
relative to the mknod change. In the mknod case, an existing device is
left as is. In the ln case, it would be forcefully overwritten.

It's not a big deal in my case (both OBS and debootstrap setup /dev
properly), but I don't know if that's important to others.

Reply via email to