On Tue, Sep 10, 2019 at 05:53:34PM BST, Todd C. Miller wrote:
> On Tue, 10 Sep 2019 16:56:42 +0100, Raf Czlonka wrote:
>
> > How about ditching dirname(1)?
>
> dirname(1) handles files in the root directory as well as files
> with no directory correctly, your diff does not.
>
> E.g.
>
> FCODES=/foo
> ${FCODES%/*} -> ""
> dirname $FCODES -> "/"
>
> FCODES=bar
> ${FCODES%/*} -> ""
> dirname $FCODES -> "."
>
> I think it best to keep dirname rather than try to reimplement it
> in the shell.
>
> - todd
Fair enough.
FYI, what prompted me to use shell instead of dirname(1) is the
recent removal of basename(1)[0] but it seems like the latter doesn't
suffer from similar edge cases :^)
[0]
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/etc/rc.d/rc.subr.diff?r1=1.131&r2=1.132&sortby=date&f=h
Thanks for pointing that out!
Raf