ualz.in 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/sh
  2. #
  3. # Written by Pavel Roskin <proski@gnu.org>
  4. # (C) 2005 The Free Software Foundation.
  5. #
  6. #
  7. UNALZ=unalz
  8. mcualz_list ()
  9. {
  10. $UNALZ -l "$1" | @AWK@ -v uid=`id -nu` -v gid=`id -ng` '
  11. {
  12. if ($1 ~ /[0-9][0-9][:/][0-9][0-9][:/][0-9][0-9]$/)
  13. {
  14. # Kludge for non-POSIX date format in unalz 0.50
  15. split($1, date, "[/:]")
  16. if (length(date[1]) == 4) {
  17. pdate = date[2] "/" date[3] "/" date[1]
  18. } else {
  19. pdate = date[1] "/" date[2] "/" date[3]
  20. }
  21. time=$2
  22. perm=$3
  23. size=$4
  24. sub(/^ *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* */, "")
  25. file=$0
  26. gsub(/\\/, "/", file)
  27. if (perm ~ /.D../)
  28. perm = "drwxr-xr-x"
  29. else
  30. perm = "-rw-r--r--"
  31. printf "%s 1 %s %s %d %s %s %s\n", perm, uid, gid, size, pdate, time, file
  32. }
  33. }
  34. '
  35. }
  36. mcualz_copyout ()
  37. {
  38. TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-ualz.XXXXXX` || exit 1
  39. # This is a workaround for a bug in unalz 0.50 - it crashes if the
  40. # output directory is an absolute path.
  41. dir=`dirname "$TMPDIR/$2"`
  42. mkdir -p "$dir"
  43. $UNALZ -d "$TMPDIR" "$1" "$2" >/dev/null
  44. cat "$TMPDIR/$2" > "$3"
  45. rm -rf "$TMPDIR"
  46. }
  47. # override any locale for dates
  48. LC_ALL=C
  49. export LC_ALL
  50. umask 077
  51. cmd="$1"
  52. shift
  53. case "$cmd" in
  54. list) mcualz_list "$@" ;;
  55. copyout) mcualz_copyout "$@" ;;
  56. *) exit 1 ;;
  57. esac
  58. exit 0