Newer
Older
libj / tool / copy-class.sh
Nomura Kei on 9 Jun 2024 733 bytes first commit
  1. #!/bin/sh
  2. #
  3. I_CLASS=$1
  4. O_CLASS=$2
  5. EXT=$3
  6. if [ "${I_CLASS}" = "" ] || [ "${O_CLASS}" = "" ] || [ "${EXT}" = "" ]; then
  7. echo "Usage) $0 in_class out_class ext > out_class_file"
  8. echo "Ex) $0 \"Exception\" \"RuntimeException\" ".hpp" > runtime_exception.hpp"
  9. exit 1
  10. fi
  11.  
  12. I_SNAKE=`echo ${I_CLASS} | sed -E 's/(.)([A-Z])/\1_\2/g'`
  13. O_SNAKE=`echo ${O_CLASS} | sed -E 's/(.)([A-Z])/\1_\2/g'`
  14.  
  15. I_LOWER=`echo "${I_SNAKE}" | tr "[:upper:]" "[:lower:]"`
  16. O_LOWER=`echo "${O_SNAKE}" | tr "[:upper:]" "[:lower:]"`
  17.  
  18. I_UPPER=`echo "${I_SNAKE}" | tr "[:lower:]" "[:upper:]"`
  19. O_UPPER=`echo "${O_SNAKE}" | tr "[:lower:]" "[:upper:]"`
  20.  
  21. sed -e "s/${I_CLASS}/${O_CLASS}/g" -e "s/${I_LOWER}/${O_LOWER}/g" -e "s/${I_UPPER}/${O_UPPER}/g" "${I_LOWER}${EXT}"
  22.