Don't assume that 'ls' output is fixed-width.
authorJim Meyering <jim@meyering.net>
Mon, 8 Dec 2003 09:04:48 +0000 (09:04 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 8 Dec 2003 09:04:48 +0000 (09:04 +0000)
tests/cp/same-file

index 4f9349e..de5cf61 100755 (executable)
@@ -74,11 +74,10 @@ for args in 'foo symlink' 'symlink foo' 'foo foo' 'sl1 sl2' 'foo hardlink'; do
        # and put brackets around the output.
        test -s _err && echo "[`sed 's/^[^:][^:]*:/cp:/' _err`]"
        # Strip off all but the file names.
-       # Omit the variable-width owner and group names.
        ls="`ls -gG --ignore=_err . \
            | sed \
                -e '/^total /d' \
-               -e 's/^......................................//'`"
+               -e 's/^[^ ]*  *[^ ]*  *[^ ]*  *[^ ]*  *[^ ]*  *[^ ]*  *//'`"
        echo "($ls)"
        # Make sure the original is unchanged and that
        # the destination is a copy.