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