mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
4f9c3415a5
Don't hardcode gawk. Don't rely on the date format occupying a fixed number of fields.
42 lines
768 B
Bash
42 lines
768 B
Bash
#! /bin/sh
|
|
|
|
# Based on previous version of lslR
|
|
# Modified by Tomas Novak <tnovak@ipex.cz> April 2000
|
|
# (to allow spaces in filenames)
|
|
|
|
ZCAT="gunzip -c"
|
|
CAT="cat"
|
|
|
|
mclslRfs_list () {
|
|
case "$1" in
|
|
*.gz) MYCAT="$ZCAT";;
|
|
*.z) MYCAT="$ZCAT";;
|
|
*.Z) MYCAT="$ZCAT";;
|
|
*) MYCAT="$CAT";;
|
|
esac
|
|
|
|
$MYCAT "$1" | @AWK@ '
|
|
BEGIN { dir="" }
|
|
/^total\ [0-9]*$/ { next }
|
|
/^$/ { next }
|
|
/^[^ ].*:$/ {
|
|
if ($0 ~ /^\//) dir=substr($0, 2);
|
|
else dir=$0;
|
|
if (dir ~ /\/:$/) sub(/:$/, "", dir);
|
|
else sub(/:$/, "/", dir);
|
|
next;
|
|
}
|
|
/:/ {
|
|
# gensub is not portable.
|
|
name=$0
|
|
sub(/^[^:]+:[^ ]+[ ]+/, "", name)
|
|
attr=substr($0, 1, length($0)-length(name))
|
|
printf "%s%s%s\n", attr, dir, name
|
|
}' 2>/dev/null
|
|
}
|
|
|
|
case "$1" in
|
|
list) mclslRfs_list "$2"; exit 0;;
|
|
esac
|
|
exit 1
|