From 5627fd2045c773a61d672151b489612539d4eab1 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 24 Sep 2016 17:07:01 +0000 Subject: [PATCH] dev tools: Stage the copyright block to make diffs smaller. --- tests/generate.zsh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/generate.zsh b/tests/generate.zsh index e0a06da..f6c32d6 100755 --- a/tests/generate.zsh +++ b/tests/generate.zsh @@ -41,9 +41,6 @@ fi buffer=$1 ZSH_HIGHLIGHT_HIGHLIGHTERS=( $2 ) fname=${0:A:h:h}/highlighters/$2/test-data/${3%.zsh}.zsh -exec 3>&1 -exec >$fname -git add -N $fname # Load the main script. . ${0:A:h:h}/zsh-syntax-highlighting.zsh @@ -54,9 +51,17 @@ _zsh_highlight_add_highlight() region_highlight+=("$1 $2 $3") } + # Copyright block -<$0 sed -n -e '1,/^$/p' | sed -e 's/2[0-9][0-9][0-9]/YYYY/' +year="`LC_ALL=C date +%Y`" +if ! read -q "?Set copyright year to $year? "; then + year="YYYY" +fi +exec >$fname +<$0 sed -n -e '1,/^$/p' | sed -e "s/2[0-9][0-9][0-9]/${year}/" echo "" +# Assumes stdout is line-buffered +git add -- $fname # Buffer print -n 'BUFFER=' @@ -87,10 +92,3 @@ print 'expected_region_highlight=(' done } print ')' - -exec >&3 -year="`LC_ALL=C date +%Y`" -if read -q "?Set copyright year to $year? "; then - <$fname >$fname.t sed s/YYYY/$year/ && - mv $fname.t $fname -fi