orig/vinfo.csh
author Axel Jacobs <axel@jaloxa.eu>
Sat, 09 Apr 2011 17:55:16 +0100
changeset 0 0aa115157c9c
permissions -rw-r--r--
Added original CSH script from HEAD-20110409.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     1
#!/bin/csh -f
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     2
# RCSid: $Id: vinfo.csh,v 3.2 2004/11/19 23:00:49 greg Exp $
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     3
#
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     4
# Edit information header in Radiance file
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     5
#
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     6
set plist=()
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     7
set ilist=()
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     8
foreach f ($*)
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
     9
	if (! -f $f:q) then
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    10
		echo "${f}: no such file or directory"
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    11
		continue
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    12
	endif
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    13
	if (! -w $f:q) then
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    14
		echo "$f is read-only"
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    15
		sleep 1
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    16
		continue
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    17
	endif
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    18
	set info="$f.info"
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    19
	getinfo < $f:q > $info:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    20
	set plist=($plist:q $f:q)
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    21
	set ilist=($ilist:q $info:q)
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    22
end
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    23
vi $ilist:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    24
set i=1
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    25
while ( $i <= $#plist )
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    26
	set f=$plist[$i]:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    27
	set info=$ilist[$i]:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    28
	if ("`tail -1 $info:q`" != "") then
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    29
		echo "" >> $info:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    30
	endif
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    31
	getinfo < $f:q | cmp -s - $info:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    32
	if ($status != 0) then
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    33
		getinfo - < $f:q >> $info:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    34
		mv $info:q $f:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    35
	else
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    36
		rm $info:q
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    37
	endif
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    38
	@ i++
0aa115157c9c Added original CSH script from HEAD-20110409.
Axel Jacobs <axel@jaloxa.eu>
parents:
diff changeset
    39
end