On Fri, Dec 05, 2025 at 10:21:36AM +0800, Zhixu Liu wrote:
> > -               # If we're still here, setcaps failed.
> > +               # If we're still here, setcaps failed or filecaps are 
> > disabled.
> > +               if [[ -n ${owner} || -n ${group} ]]; then
> > +                       debug-print "${FUNCNAME}: setting owner on 
> > '${file}'"
> > +                       chown "${owner}:${group}" "${file}" || die
> > +               fi
> 
> if owner is a number but no group, chown will fail w/ "chown: invalid

Huh, never realized this, kind of assumed it worked given `root:` does.

> spec: '2000:'", how about:
> 
> local spec=${owner}
> [[ -n ${group} ]] && spec+=":${group}"
> 
> chown "${spec}" "${file}" || die

Could keep it as a one-liner using ${var:+}, aka:

    chown "${owner}${group:+:}${group}" "${file}" || die

For those that don't know :+ checks if group is empty and,
if not, will print what's after it aka :.

> 
> >                 if [[ -n ${mode} ]]; then
> > -                       if [[ -n ${owner} || -n ${group} ]]; then
> > -                               debug-print "${FUNCNAME}: setting owner on 
> > '${file}'"
> > -                               chown "${owner}:${group}" "${file}" || die
> > -                       fi
> >                         debug-print "${FUNCNAME}: setting mode on '${file}'"
> >                         chmod ${mode} "${file}" || die
> >                 fi
> > --
> > 2.52.0
> >
> >
> 
> 
> -- 
> Z. Liu
> 

-- 
ionen

Attachment: signature.asc
Description: PGP signature

Reply via email to