Jim Meyering wrote:
> +# Emulate dirname with sed.
> +# This approximation fails when the input is a single-component
> +# absolute directory name like /foo, but that never happens here.
> +approx_dirname_filter = sed 's,^[^/]*$$,.,;s,//*[^/]*$$,,'

Oops, sorry for suggesting a bad approximation. Here's a better one:
approx_dirname_filter = sed 
's,^[^/]*$$,.,;s,^/[^/]*$$,/,;s,\([^/]\)//*[^/]*$$,\1,'

Tested like this:
$ { echo abc; echo abc/def ; echo / ; echo /doo; echo /foo/bar; echo //foo; } \
  | sed 's,^[^/]*$,.,;s,^/[^/]*$,/,;s,\([^/]\)//*[^/]*$,\1,'
.
abc
/
/
/foo
//foo


Bruno



_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to