update-years.sh 621 B

123456789101112131415161718192021222324
  1. #! /bin/sh
  2. YEAR=`date +%Y`
  3. SOURCES="`find lib src tests -name '*.c'`"
  4. SOURCES="$SOURCES src/man2hlp/man2hlp.in"
  5. LINE="Copyright (C)"
  6. for i in $SOURCES; do
  7. # replace year: XXXX-YYYY -> XXXX-ZZZZ
  8. # add year: XXXX -> XXXX-ZZZZ
  9. ${SED-sed} -e "
  10. 1,20 {
  11. /$LINE/s/-[0-9]\{4\}$/-$YEAR/
  12. };
  13. 1,20 {
  14. /$LINE/s/ [0-9]\{4\}$/&-$YEAR/
  15. }" $i > $i.tmp && mv -f $i.tmp $i
  16. done
  17. # special case
  18. ${SED-sed} -e "/$LINE/s/-[0-9]\{4\} the/-$YEAR the/" src/editor/editwidget.c > src/editor/editwidget.c.tmp && \
  19. mv -f src/editor/editwidget.c.tmp src/editor/editwidget.c