Главная страница


ru.linux

 
 - RU.LINUX ---------------------------------------------------------------------
 From : Max Ischenko                         2:5020/400     31 Jan 2002  11:20:42
 To : Valery Shishkov
 Subject : Re: Пpогpаммиpование
 -------------------------------------------------------------------------------- 
 
 
  Valery Shishkov wrote:
 
 VS> Hу, не совсем в shell, но при наличии afs можно прям из shell'а унутрь
 VS> архива лазать (говорят :).
 
 Без всяких avfs за час пишется вот такой простенький скриптик:
 
 #!/bin/sh
 
 [ $# -eq 0 ] && { echo "what file to view?"; exit 1; }
 file=$1
 type=${file##*.}
 
 TMPDIR=${TMPDIR:-/var/tmp}
 temp=$TMPDIR/viewar.$$
 trap 'rm -fr $temp' 0 1 2 15
 
 unexec () { find . -type f |xargs chmod 644; }
 extract_rpm () { rpm2cpio "$1" | cpio -iumd --quiet; }
 extract_zip () { unzip -Lq "$1"; unexec; }
 extract_rar () { unrar x "$1"; unexec; }
 extract_arj () { unarj x "$1"; unexec; }
 extract_tar () { tar $1 "$2"; }
   
 case $type in
   rpm) extract=extract_rpm ;;
   gz|tgz) extract="extract_tar xzf" ;;
   bz2) extract="extract_tar xjf" ;;
   tar) extract="extract_tar xf" ;;
   taz) extract="extract_tar xZf" ;;
   zip|ZIP) extract=extract_zip ;;
   rar|RAR) extract=extract_rar ;;
   arj|ARJ) extract=extract_arj ;;
   *) echo "$file: unsupported archive type $type"; exit 1;;
 esac
 
 file=`realpath "$file"` # Get an absolute pathname
 mkdir $temp
 cd $temp
 $extract "$file"
 # If we have single directory and nothing else, let's cd there.
 dirs=`ls -d * 2>/dev/null |wc -l`
 [ $dirs -eq 1 ] && cd */
 /bin/bash2
 # Hаписание realpath left as an exercise to the reader. ;)
 -- 
 A language that doesn't affect the way you think about programming is
 not worth knowing.
 --- ifmail v.2.15dev5
  * Origin: somewhere in space... (2:5020/400)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 Re: Пpогpаммиpование   Max Ischenko   31 Jan 2002 11:20:42 
Архивное /ru.linux/1618108722b4f.html, оценка 2 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional