mc/vfs/extfs/lslR.in
Pavel Roskin b1c7fda53b Set locale to C.
Add support for bzip2.
Remove redirection of stderr to /dev/null.
2002-12-12 08:34:24 +00:00

50 lines
1006 B
Bash

#! /bin/sh
# Based on previous version of lslR
# Modified by Tomas Novak <tnovak@ipex.cz> April 2000
# (to allow spaces in filenames)
#
# It's assumed that lslR was generated in C locale.
mclslRfs_list () {
case "$1" in
*.bz2) MYCAT="bzip2 -dc";;
*.gz) MYCAT="gzip -dc";;
*.z) MYCAT="gzip -dc";;
*.Z) MYCAT="gzip -dc";;
*) MYCAT="cat";;
esac
$MYCAT "$1" | @AWK@ '
BEGIN {
dir="";
# Pattern to match 8 first fields.
rx = "[^ ]+[ ]+";
rx = "^" rx rx rx rx rx rx rx rx;
}
/^total\ [0-9]*$/ { next }
/^$/ { next }
/^[^ ].*:$/ {
if ($0 ~ /^\//) dir=substr($0, 2);
else dir=$0;
if (dir ~ /\/:$/) sub(/:$/, "", dir);
else sub(/:$/, "/", dir);
next;
}
{ $9 != "" } {
# gensub() is not portable.
name=$0
sub(rx, "", name)
# Cannot assign to $9, or spaces in the filename would be reduced.
attr=substr($0, 1, length($0)-length(name))
printf "%s%s%s\n", attr, dir, name
}'
}
export LC_ALL="C"
case "$1" in
list) mclslRfs_list "$2"; exit 0;;
esac
exit 1