/[gentoo-x86]/eclass/fixheadtails.eclass
Gentoo

Contents of /eclass/fixheadtails.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Fri Dec 10 23:17:11 2004 UTC (10 years, 1 month ago) by johnm
Branch: MAIN
Changes since 1.3: +2 -1 lines
Fixes bug #65593

1 vapier 1.3 # Copyright 1999-2004 Gentoo Foundation
2 johnm 1.1 # Distributed under the terms of the GNU General Public License v2
3 johnm 1.4 # $Header: /var/cvsroot/gentoo-x86/eclass/fixheadtails.eclass,v 1.3 2004/06/25 00:39:48 vapier Exp $
4 johnm 1.1 #
5     # Author John Mylchreest <johnm@gentoo.org>
6    
7     ECLASS=fixheadtails
8     INHERITED="$INHERITED $ECLASS"
9 mr_bones_ 1.2 DEPEND="${DEPEND} >=sys-apps/sed-4"
10 johnm 1.1
11     # ht_fix_all
12     # This fixes all files within the current directory.
13     # Do be used in src_unpack ; cd ${S}; ht_fix_all
14    
15     # ht_fix_file <param> [<param>] [<param>]..
16     # This fixes the files passed by PARAM
17     # to be used for specific files. ie: ht_fix_file "${FILESDIR}/mypatch.patch"
18    
19 mr_bones_ 1.2 do_sed_fix() {
20     sed -i \
21     -e 's/head -\(.*\)/head -n \1/' \
22 johnm 1.4 -e 's/tail \([-+]\)\(.*\)c/tail -c \1\2/' \
23 mr_bones_ 1.2 -e 's/tail \([-+]\)\(.*\)/tail -n \1\2/' ${1} || \
24     die "sed ${1} failed"
25 johnm 1.1 }
26    
27     ht_fix_file() {
28     local i
29    
30 mr_bones_ 1.2 einfo "Replacing obsolete head/tail with POSIX compliant ones"
31 johnm 1.1 for i in "${@}"
32     do
33 mr_bones_ 1.2 do_sed_fix ${i}
34 johnm 1.1 done
35 mr_bones_ 1.2 }
36    
37     ht_fix_all() {
38     local MATCHES
39     MATCHES="$(grep -l -i -R -e "head -[ 0-9]" -e "tail [+-][ 0-9]" * | sort -u)"
40     ht_fix_file ${MATCHES}
41 johnm 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20