xref: /freebsd/contrib/dialog/rename.sh (revision d1d015864103b253b3fcb2f72a0da5b0cfeb31b6)
17a1c0d96SNathan Whitehorn#! /bin/sh
2*2a3e3873SBaptiste Daroussin# $Id: rename.sh,v 1.4 2012/12/19 10:17:36 tom Exp $
37a1c0d96SNathan Whitehorn##############################################################################
4*2a3e3873SBaptiste Daroussin# Copyright (c) 2011,2012 Thomas E. Dickey                                   #
57a1c0d96SNathan Whitehorn#                                                                            #
67a1c0d96SNathan Whitehorn# Permission is hereby granted, free of charge, to any person obtaining a    #
77a1c0d96SNathan Whitehorn# copy of this software and associated documentation files (the "Software"), #
87a1c0d96SNathan Whitehorn# to deal in the Software without restriction, including without limitation  #
97a1c0d96SNathan Whitehorn# the rights to use, copy, modify, merge, publish, distribute, distribute    #
107a1c0d96SNathan Whitehorn# with modifications, sublicense, and/or sell copies of the Software, and to #
117a1c0d96SNathan Whitehorn# permit persons to whom the Software is furnished to do so, subject to the  #
127a1c0d96SNathan Whitehorn# following conditions:                                                      #
137a1c0d96SNathan Whitehorn#                                                                            #
147a1c0d96SNathan Whitehorn# The above copyright notice and this permission notice shall be included in #
157a1c0d96SNathan Whitehorn# all copies or substantial portions of the Software.                        #
167a1c0d96SNathan Whitehorn#                                                                            #
177a1c0d96SNathan Whitehorn# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
187a1c0d96SNathan Whitehorn# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
197a1c0d96SNathan Whitehorn# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
207a1c0d96SNathan Whitehorn# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
217a1c0d96SNathan Whitehorn# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
227a1c0d96SNathan Whitehorn# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
237a1c0d96SNathan Whitehorn# DEALINGS IN THE SOFTWARE.                                                  #
247a1c0d96SNathan Whitehorn#                                                                            #
257a1c0d96SNathan Whitehorn# Except as contained in this notice, the name(s) of the above copyright     #
267a1c0d96SNathan Whitehorn# holders shall not be used in advertising or otherwise to promote the sale, #
277a1c0d96SNathan Whitehorn# use or other dealings in this Software without prior written               #
287a1c0d96SNathan Whitehorn# authorization.                                                             #
297a1c0d96SNathan Whitehorn##############################################################################
307a1c0d96SNathan Whitehorn# install-helper for dialog's manpages, e.g., as "cdialog".
317a1c0d96SNathan Whitehorn#
327a1c0d96SNathan Whitehorn# $1 = input file
337a1c0d96SNathan Whitehorn# $2 = output file
347a1c0d96SNathan Whitehorn# $3 = actual program name that dialog is installed as
357a1c0d96SNathan Whitehorn# $4 = actual name that header/library are installed as
367a1c0d96SNathan Whitehorn# $5+ = install program and possible options
377a1c0d96SNathan Whitehorn
387a1c0d96SNathan WhitehornLANG=C;     export LANG
397a1c0d96SNathan WhitehornLC_ALL=C;   export LC_ALL
407a1c0d96SNathan WhitehornLC_CTYPE=C; export LC_CTYPE
417a1c0d96SNathan WhitehornLANGUAGE=C; export LANGUAGE
427a1c0d96SNathan Whitehorn
437a1c0d96SNathan WhitehornSOURCE=$1; shift
447a1c0d96SNathan WhitehornTARGET=$1; shift
457a1c0d96SNathan WhitehornBINARY=$1; shift
467a1c0d96SNathan WhitehornPACKAGE=$1; shift
477a1c0d96SNathan Whitehorn
487a1c0d96SNathan WhitehornCHR_LEAD=`echo "$BINARY" | sed -e 's/^\(.\).*/\1/'`
497a1c0d96SNathan WhitehornCHR_TAIL=`echo "$BINARY" | sed -e 's/^.//'`
507a1c0d96SNathan WhitehornONE_CAPS=`echo $CHR_LEAD | tr '[a-z]' '[A-Z]'`$CHR_TAIL
517a1c0d96SNathan WhitehornALL_CAPS=`echo "$BINARY" | tr '[a-z]' '[A-Z]'`
527a1c0d96SNathan Whitehorn
537a1c0d96SNathan Whitehornsed	-e "s,^\.ds p dialog\>,.ds p $BINARY," \
547a1c0d96SNathan Whitehorn	-e "s,^\.ds l dialog\>,.ds l $PACKAGE," \
557a1c0d96SNathan Whitehorn	-e "s,^\.ds L Dialog\>,.ds L $ONE_CAPS," \
567a1c0d96SNathan Whitehorn	-e "s,^\.ds D DIALOG\>,.ds D $ALL_CAPS," \
57*2a3e3873SBaptiste Daroussin	-e 's,^dialog \\- ,'"$PACKAGE"' \\- ,' \
587a1c0d96SNathan Whitehorn	<$SOURCE >source.tmp
597a1c0d96SNathan Whitehorn"$@" source.tmp $TARGET
607a1c0d96SNathan Whitehornrm -f source.tmp
61