bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ls --sort=none -r


From: Dave Yost
Subject: Re: ls --sort=none -r
Date: Tue, 12 Sep 2006 19:40:11 -0700

At 02:49 PM -0700 2006-09-12, Paul Eggert wrote:
>Dave Yost <address@hidden> writes:
>
>> The -r should reverse the (unsorted) order.
>
>But POSIX+XSI requires that -r must be turned off
>if unsorted order is specified (the -f option).  See
><http://www.opengroup.org/onlinepubs/009695399/utilities/ls.html>.
>
>Surely there's not much call for reversing a raw directory.

It's not about reversing a raw directory.  It's about doing ls -l of several 
items in the order specified.   Below is 'not much call' for it. ;-)

>You can filter the output with 'tac' if that's what you really want.

Clearly this is a bug in the POSIX+XSI specification.

Dave


#!/bin/zsh

# 0 1192 Z% llpath
# drwxrwxr-t   66 root     admin        2346 Sep 12 16:12 /
# drwxrwxr-t   18 root     admin         612 Jul 12 21:08 /Users
# drwxrwx--x  160 yost     admin        5440 Sep 12 15:13 /Users/yost
# drwx------  120 yost     admin        4080 Aug 28 19:27 /Users/yost/Documents
# drwxrwxrwx   23 yost     admin         782 Oct 12  2004 
/Users/yost/Documents/Goons
# drwxrwxrwx   19 yost     admin         646 Oct 12  2004 
/Users/yost/Documents/Goons/Goon Show Depository
# 0 1193 Z%

# Get the GNU version of ls
PATH="/sw/bin:$PATH"

if [[ $# = 0 ]] ; then
  pathname="$(pwd)"
else
  pathname="$1"
  if [[ ${pathname##/} = "$pathname"  ]] ; then pathname=`pwd`/$pathname ; fi
fi

all=()

while true ; do
  if [[ ! -e "$pathname" ]] ; then
    echo 1>&2 "llpath: $pathname: No such file or directory"
    exit 2
  fi
  if [[ -L "$pathname" ]] ; then
    all=($(realpath "$pathname") $all)
  fi
  all=("$pathname" $all)
  if [[ "$pathname" = . || "$pathname" = / ]] ; then
    break
  fi
  pathname="$pathname:h"
done

#echo "address@hidden" | fmt -1

ls -ld --sort=none "address@hidden"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]