Replaced remaining grep with @GREP@ in iso9660 VFS plugin.
[midnight-commander/osp/podlajak.git] / lib / vfs / mc-vfs / extfs / iso9660.in
blob2522cba232753f3a91e3e49351ce45108fd309ba
1 #! /bin/sh
3 # ISO9660 VFS for MC by Michael Shigorin <mike@altlinux.org>,
4 # modifications by Grigory Milev <week@altlinux.org>
5 # and Kachalov Anton <mouse@linux.ru.net> April 2003
6 # based on lslR by Tomas Novak <tnovak@ipex.cz> April 2000
7 # -- look there for additional parsing comments if needed
9 # tested to comply with isoinfo 2.0's output
11 test_iso () {
12 CHARSET=`locale charmap 2>/dev/null`
13 if test -z "$CHARSET"; then
14 CHARSET=`locale 2>/dev/null | @GREP@ LC_CTYPE | sed -n -e 's/.*\.\(.*\)"$/\1/p'`
16 if test -n "$CHARSET"; then
17 CHARSET=`echo "$CHARSET" | tr '[A-Z]' '[a-z]' | sed -e 's/^iso-/iso/'`
18 isoinfo -j $CHARSET -i /dev/null 2>&1 | @GREP@ "Iconv not yet supported\|Unknown charset" >/dev/null && CHARSET=
20 if test -n "$CHARSET"; then
21 JOLIET_OPT="-j $CHARSET -J"
22 else
23 JOLIET_OPT="-J"
25 ISOINFO="isoinfo -R"
26 isoinfo -d -i "$1" 2>/dev/null | @GREP@ "UCS level 1\|NO Joliet" > /dev/null || ISOINFO="$ISOINFO $JOLIET_OPT"
29 mcisofs_list () {
30 # left as a reminder to implement compressed image support =)
31 case "$1" in
32 *.lzma) MYCAT="lzma -dc";;
33 *.xz) MYCAT="xz -dc";;
34 *.bz2) MYCAT="bzip2 -dc";;
35 *.gz) MYCAT="gzip -dc";;
36 *.z) MYCAT="gzip -dc";;
37 *.Z) MYCAT="gzip -dc";;
38 *) MYCAT="cat";;
39 esac
41 $ISOINFO -l -i "$1" | @AWK@ '
42 BEGIN {
43 dir="";
44 # Pattern to match 8 first fields.
45 rx = "[^ ]+[ ]+";
46 rx = "^" rx rx rx rx rx rx rx rx;
47 irx = "^\\[ *-?[0-9]* *[0-9]+\\] +";
49 /^$/ { next }
50 /^d---------/ { next }
51 /^Directory listing of [^ ].*$/ {
52 dir=substr($0, 23);
53 next;
55 { $11 != "" } {
56 name=$0
57 sub(rx, "", name)
58 attr=substr($0, 1, length($0)-length(name))
59 # strip inodes and extra dir entries; fix perms
60 sub(irx, "", name)
61 sub("^---------- 0 0 0", "-r--r--r-- 1 root root", attr)
62 sub(" $", "", name)
63 ## sub(";[0-9]+$", "", name) ## would break copyout
64 # skip . and ..
65 if (name ~ /^\.\.?/) next;
66 printf "%s%s%s\n", attr, dir, name
67 }'
70 mcisofs_copyout () {
71 $ISOINFO -i "$1" -x "/$2" > "$3"
74 LC_ALL=C
76 cmd="$1"
77 shift
79 case "$cmd" in
80 list)
81 test_iso "$@";
82 mcisofs_list "$@";
83 exit 0;;
84 copyout)
85 test_iso "$@";
86 mcisofs_copyout "$@";
87 exit 0;;
88 esac
89 exit 1