-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
103 lines (90 loc) · 2.99 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!fish -f
## install 0.2 ## Copyright(C)1993 by Itagaki Fumihiko
######################################################################
# もし必要なら,以下のコマンドに起動パスを加えてください.
######################################################################
set mv=( mv ) # ITA mv v1.5~
set cp=( cp ) # ITA cp v1.4~
set chmod=( chmod ) # ITA chmod v1.4~
set strip=( strip ) # ITA strip v1.2~
set lzx=( lzx ) # F&I LZX v0.43.4(h)+Junk ※ -r は指定できません
######################################################################
set mi="$0:t"
if( $FISH_VERSION[1] == 0 && $FISH_VERSION[2] < 8 ) \
echo -2 "${mi}: version 0.8.2 以降の fish をインストールしてください" ; exit 1
function do_install() {
if( ! -e "$1" ) echo -2 "${mi}: ${1}: このようなファイルはありません" ; @ status=2; return
if( ! -f "$1" ) echo -2 "${mi}: ${1}: 通常のファイルではありません" ; @ retval=2 ; return
if( ! $?install_copy && -l "$1" ) echo -2 "${mi}: ${1}: シンボリック・リンクを移動することはできません" ; @ retval=2 ; return
if( ! { $cmd:q -f -- "$1" "$2" } ) @ retval=$? ; return
if( $?dostrip ) then
$strip:q -- "$2" >& NUL
if( $?dolzx && ( $? == 0 || "$2" =~ *.[rR] ) ) then
cd $temp
@ ab=( -e "$2:t" )
if( $ab ) $mv:q -f -- "$2:t" "#$$#"
$lzx:q "$2"
if( -e "$2:t" ) $mv:q -f -- "$2:t" "$2"
if( $ab ) $mv:q -f -- "#$$#" "$2:t"
cd -
endif
endif
if( "$modexp1$modexp2" != "" && ! { $chmod:q "$modexp1$modexp2" "$2" } ) @ retval=$?
}
set cmd=( $mv:q ) modexp1="=arx," modexp2
getopt cpsvxzm:
while( $#options )
switch( $options[1] )
case c:
set install_copy cmd=( $cp:q ) ; breaksw
case p:
set predict modexp1 ; breaksw
case z:
set dolzx
case s:
set dostrip ; breaksw
case v:
set doverbose ; breaksw
case x:
set suppress_x ; breaksw
case m:
shift options
set modexp2="$options[1]"
if( "$modexp2" =~ [0-7]* ) set modexp1
breaksw
default:
goto usage
endsw
shift options
end
if( $# < 2 ) then
echo -2 "${mi}: 引数が足りません"
usage:
echo -2 "使用法: $mi [-cpsvz] [-m <属性変更式>] [--] <ファイル> <インストール先のパス名>"
echo -2 " $mi [-cpsvzx] [-m <属性変更式>] [--] <ファイル> ... <インストール先ディレクトリ>"
echo -2
echo -2 " 属性変更式: {[ugoa]{{+-=}[ashrwx]}...}[,...] または 8進数値表現"
exit 1
endif
if( $?dolzx ) then
if( $?temp == 0 ) echo -2 "${mi}: 環境変数 temp が設定されていません" ; exit 1
if( ! -d $temp ) echo -2 "${mi}: 環境変数 temp が指すディレクトリ $temp が存在しません" ; exit 1
endif
if( $?predict && $?install_copy ) set cmd=( $cp:q -p )
if( $?doverbose ) set cmd=( $cmd:q -v )
@ retval=0
set target="$argv[$#]"
if( -d "$target" ) then
while( $# >= 2 )
if( $?suppress_x && "$1" =~ *.[xX] ) then
do_install "$1" "$target:/$1:t:r"
else
do_install "$1" "$target:/$1:t"
endif
shift
end
else
if( $# > 2 ) echo -2 "${mi}: ${target}: ディレクトリではありません" ; exit 2
do_install $*:q
endif
exit $retval