File: fixpaths

package info (click to toggle)
libcdk-perl 20240606-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,732 kB
  • sloc: perl: 6,146; sh: 3,599; makefile: 28
file content (47 lines) | stat: -rwxr-xr-x 807 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
# $Id: fixpaths,v 1.2 2022/10/20 00:33:09 tom Exp $
#
# Run this script to update the paths in scripts under the current directory
# which have perl's pathname, so they can be run in your configuration.
#

save_IFS="$IFS"
IFS=':'
PERL=perl
for p in $PATH
do
	if [ -f "$p/perl" ]
	then
		PERL="$p/perl"
		break
	fi
done
IFS="$save_IFS"

TEXT="#!$PERL -w"
find . -type f -print | while read name
do
	case $name in
	*~)	;;
	*)
		head=`head -1 "$name"`
		case $head in #(vi
		\#!*perl*) #(vi
			echo "process $name"
			if test "$TEXT" != "$head" ; then
				echo "...updating "
				rm -f "${name}"~
				mv "${name}" "${name}"~
				sed -e "s@$head@$TEXT@" "${name}"~ >"${name}"
				chmod +x "${name}"
			else
				echo "...unchanged"
			fi
			;;
		*)
			# echo ignored $name
			;;
		esac
		;;
	esac
done