File: rename.sh

package info (click to toggle)
tapecalc 20240110-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,172 kB
  • sloc: sh: 3,668; ansic: 2,470; makefile: 103
file content (33 lines) | stat: -rwxr-xr-x 905 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
#! /bin/sh
# $Id: rename.sh,v 1.3 2018/07/01 17:06:39 tom Exp $
# install-helper for add's manpage and help-file.
#
# $1 = input file
# $2 = actual name that "add" is installed as
# $2 = output filename
# $4+ = install program and possible options

LANG=C;     export LANG
LC_ALL=C;   export LC_ALL
LC_CTYPE=C; export LC_CTYPE
LANGUAGE=C; export LANGUAGE

SOURCE=$1; shift
BINARY=$1; shift
TARGET=$1; shift

CHR_LEAD=`echo "$BINARY" | sed -e 's/^\(.\).*/\1/'`
CHR_TAIL=`echo "$BINARY" | sed -e 's/^.//'`
ONE_CAPS=`echo $CHR_LEAD | tr '[a-z]' '[A-Z]'`$CHR_TAIL
ALL_CAPS=`echo "$BINARY" | tr '[a-z]' '[A-Z]'`
UNDERLINE=`echo "$BINARY"| sed -e 's/./-/g'`

sed	-e "s,\<fBadd\>,fB$BINARY,g" \
	-e "s,\<fBAdd\>,fB$ONE_CAPS,g" \
	-e "s,\<fBADD\>,fB$ALL_CAPS,g" \
	-e "s,\<ADD\>,$ALL_CAPS,g" \
	-e "s,\<add\>,$BINARY,g" \
	-e "s,---,$UNDERLINE," \
	<$SOURCE >source.tmp
"$@" source.tmp "$TARGET"
rm -f source.tmp