File: ln-if-absent.beos

package info (click to toggle)
ncbi-tools6 6.1.20120620-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 241,628 kB
  • ctags: 101,236
  • sloc: ansic: 1,431,713; cpp: 6,248; pascal: 3,949; xml: 3,390; sh: 3,090; perl: 1,077; csh: 488; makefile: 449; ruby: 93; lisp: 81
file content (104 lines) | stat: -rwxr-xr-x 1,701 bytes parent folder | download | duplicates (12)
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
104
#!/bin/sh -f
#
# Make a symbolic link if the target is absent.
#
# Use this script instead "ln-if-absent" (rename it) on BeOS
#
# Untested. Contributed by Howard Feldman <feldman@mshri.on.ca>
#
# $Id: ln-if-absent.beos,v 6.1 2002/06/17 14:26:44 ivanov Exp $
#

if [ $# -lt 1 ]; then
   echo "Usage: $0 source_file... target"
   exit 1
fi

COUNT=$#
NUMARG=$#
LIST=
while [ $COUNT -ge 1 ]; do
    if [ $COUNT -eq 1 ]; then
        TARGET=$1
    else
        export LIST="$1 $LIST"
    fi
    shift
    let COUNT=$COUNT-1
done
FINAL=

if [ -d $TARGET ]; then
    for i in $LIST; do      
        if [ -r $TARGET/$i:t ]; then
            echo .
        else
            export FINAL="$FINAL $i"
        fi 
    done
else
    if [ $NUMARG -ne 2 ]; then
        echo target argument should be a directory
        exit 1
    fi
    if [ -r $LIST ]; then
        echo .
    else
        exit 1
    fi
    if [ -r $TARGET ]; then
        echo .
    else 
        ln -sf $LIST $TARGET
    fi 
    exit 0
fi

if [ ${#FINAL} == 1 ]; then
    if [ -r $FINAL ]; then
        echo .
    else
        exit 1
    fi
    ln -s $FINAL $TARGET
    exit 0
fi

if [ ${#FINAL} -ne 0 ]; then
    ln -s $FINAL $TARGET
fi

exit 0


@ count=$#argv
set target=$argv[$count]
@ count--
set list=($argv[-$count])
set final=()

if (-d $target) then
	foreach i ($list)	
		if (! -r $target/$i:t) set final=($final $i)
	end
else
	if ($#argv != 2) then
		echo target argument should not be a directory
		exit 1
	endif
	if (! -r "$1") exit 1
	if (! -r "$2") ln -sf "$1" "$2" 
	exit 0
endif

if ( $#final == 1) then
	if (! -r "$final") exit 1
	ln -s $final $target
	exit 0
endif

if ($#final != 0) then
	ln -s $final $target
endif

exit 0