-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverlist
More file actions
executable file
·71 lines (62 loc) · 1.65 KB
/
Copy pathverlist
File metadata and controls
executable file
·71 lines (62 loc) · 1.65 KB
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
#! /bin/csh -f
# Name the versions of a file, within a given range.
# Assuming the version number is just tacked on as an extension.
# verlist BASE RANGE FULL
# RANGE may be a number, or 2 numbers separated by a colon (:).
# A positive number stands for that version number. A non-positive
# number stands for the highest-numbered version plus that number.
# Eg, 0 stands for the highest numbered version.
#
# FULL = 1 outputs full filenames
# FULL = 0 outputs only version numbers
set self = verlist
set botch = 0
alias warning 'echo $self\: "***WARNING***" \!*; set botch=1'
set noglob
# get command line arguments
set file = $1; shift
if ( $#argv > 2 ) then
warning EXCESS ARGUMENTS -- IGNORED
endif
set range = (`echo $1 | tr ':' ' '`)
set full = $2
# put range in normal form
if ( $#range > 2 ) then
warning ILL-FORMED RANGE IN $x
exit $botch
endif
if ( $#range < 1 ) \
set range = (1 0)
if ( $#range == 1 ) \
set range = ($range $range)
# get full list of versions
unset noglob
set l = (/dev/[n]ull $file.[0-9]*)
set noglob
shift l
if ( $#l <= 0 ) then
# warning NO VERSIONS PRESENT OF $x
exit $botch
endif
# put in numeric order (stripped of basename)
set l = (`echo ${l:ge} | tr ' ' '\12' | sort -n`)
# handle non-positive numbers
if ( $range[1] <= 0 ) \
@ range[1] = $l[$#l] + $range[1]
if ( $range[2] <= 0 ) \
@ range[2] = $l[$#l] + $range[2]
# build output list
set i = ()
foreach x ($l)
if ( $full == 1) then
if ( $range[1] <= $x && $x <= $range[2] ) \
set i = ($i $file.$x)
else
if ( $range[1] <= $x && $x <= $range[2] ) \
set i = ($i $x)
endif
end
# finally echo the output list
echo $i
unset noglob
exit $botch