1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: fixheadtails.eclass
7 # base-system@gentoo.org
9 # Original author John Mylchreest <johnm@gentoo.org>
10 # @BLURB: functions to replace obsolete head/tail with POSIX compliant ones
12 DEPEND=">=sys-apps/sed-4"
17 -e 's/head \+-\([0-9]\)/head -n \1/g' \
18 -e 's/tail \+\([-+][0-9]\+\)c/tail -c \1/g' \
19 -e 's/tail \+\([-+][0-9]\)/tail -n \1/g' ${1} || \
23 # @FUNCTION: ht_fix_file
26 # Fix all the specified files.
29 einfo "Replacing obsolete head/tail with POSIX compliant ones"
35 # @FUNCTION: ht_fix_all
37 # Find and fix all files in the current directory as needed.
40 MATCHES=$(grep -l -s -i -R -e "head -[ 0-9]" -e "tail [+-][ 0-9]" * | sort -u)
42 && ht_fix_file ${MATCHES} \
43 || einfo "No need for ht_fix_all anymore !"