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

Diff of /eclass/fixheadtails.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.5 Revision 1.6
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/fixheadtails.eclass,v 1.5 2005/01/22 00:02:08 langthang Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/fixheadtails.eclass,v 1.6 2005/02/10 00:08:08 vapier Exp $
4# 4#
5# Author John Mylchreest <johnm@gentoo.org> 5# Author John Mylchreest <johnm@gentoo.org>
6 6
7ECLASS=fixheadtails 7ECLASS=fixheadtails
8INHERITED="$INHERITED $ECLASS" 8INHERITED="$INHERITED $ECLASS"
15# ht_fix_file <param> [<param>] [<param>].. 15# ht_fix_file <param> [<param>] [<param>]..
16# This fixes the files passed by PARAM 16# This fixes the files passed by PARAM
17# to be used for specific files. ie: ht_fix_file "${FILESDIR}/mypatch.patch" 17# to be used for specific files. ie: ht_fix_file "${FILESDIR}/mypatch.patch"
18 18
19do_sed_fix() { 19do_sed_fix() {
20 einfo " - fixed $1"
20 sed -i \ 21 sed -i \
21 -e 's/head \+-\([0-9]\)/head -n \1/g' \ 22 -e 's/head \+-\([0-9]\)/head -n \1/g' \
22 -e 's/tail \+\([-+][0-9]\+\)c/tail -c \1/g' \ 23 -e 's/tail \+\([-+][0-9]\+\)c/tail -c \1/g' \
23 -e 's/tail \+\([-+][0-9]\)/tail -n \1/g' ${1} || \ 24 -e 's/tail \+\([-+][0-9]\)/tail -n \1/g' ${1} || \
24 die "sed ${1} failed" 25 die "sed ${1} failed"
35} 36}
36 37
37ht_fix_all() { 38ht_fix_all() {
38 local MATCHES 39 local MATCHES
39 MATCHES="$(grep -l -i -R -e "head -[ 0-9]" -e "tail [+-][ 0-9]" * | sort -u)" 40 MATCHES="$(grep -l -i -R -e "head -[ 0-9]" -e "tail [+-][ 0-9]" * | sort -u)"
41 [[ -n ${MATCHES} ]] \
40 ht_fix_file ${MATCHES} 42 && ht_fix_file ${MATCHES} \
43 || einfo "No need for ht_fix_all anymore !"
41} 44}

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.20