lslR.in 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #! /bin/sh
  2. # Based on previous version of lslR
  3. # Modified by Tomas Novak <tnovak@ipex.cz> April 2000
  4. # (to allow spaces in filenames)
  5. #
  6. # It's assumed that lslR was generated in C locale.
  7. LC_ALL=C
  8. export LC_ALL=C
  9. AWK=@AWK@
  10. mclslRfs_list () {
  11. case "$1" in
  12. *.lzma) MYCAT="lzma -dc";;
  13. *.xz) MYCAT="xz -dc";;
  14. *.bz2) MYCAT="bzip2 -dc";;
  15. *.gz) MYCAT="gzip -dc";;
  16. *.z) MYCAT="gzip -dc";;
  17. *.Z) MYCAT="gzip -dc";;
  18. *) MYCAT="cat";;
  19. esac
  20. $MYCAT "$1" | $AWK '
  21. BEGIN {
  22. dir="";
  23. # Pattern to match 8 first fields.
  24. rx = "[^ ]+[ ]+";
  25. rx = "^" rx rx rx rx rx rx rx rx;
  26. }
  27. /^total\ [0-9]*$/ { next }
  28. /^$/ { next }
  29. /^[^ ].*:$/ {
  30. if ($0 ~ /^\//) dir=substr($0, 2);
  31. else dir=$0;
  32. if (dir ~ /\/:$/) sub(/:$/, "", dir);
  33. else sub(/:$/, "/", dir);
  34. next;
  35. }
  36. ( $9 != "" ) {
  37. # gensub() is not portable.
  38. name=$0
  39. sub(rx, "", name)
  40. # Cannot assign to $9, or spaces in the filename would be reduced.
  41. attr=substr($0, 1, length($0)-length(name))
  42. printf "%s%s%s\n", attr, dir, name
  43. }'
  44. }
  45. case "$1" in
  46. list) mclslRfs_list "$2"; exit 0;;
  47. esac
  48. exit 1