view new_slide.sh @ 13:62d6bd64af0a

Mini refactor new_slide.sh
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Sat, 01 Feb 2014 00:10:16 +0900
parents 213c5de5d47d
children
line wrap: on
line source

#!/bin/sh

cd $(dirname $0)

# import definitions
. config/definition.sh

# function

dirname_from_day_of_the_week() {

    case $1 in
        "mon") week_of_day="next Mon." ;;
        "tue") week_of_day="next Tue." ;;
        "wed") week_of_day="next Wed." ;;
        "thu") week_of_day="next Thu." ;;
        "fri") week_of_day="next Fri." ;;
        "sat") week_of_day="next Sat." ;;
        "sun") week_of_day="next Sun." ;;

        *) week_of_day=""   # default is empty value, it's today
    esac

    if [[  $(uname) == Darwin ]]; then
        command="gdate"     # --date option is supported by GNU date
    else
        command="date"
    fi

    ${command} --date="${week_of_day}" +"${slide_date_format}"
}

# main

slide_dirname=`dirname_from_day_of_the_week ${1}`
dir_full_path="${slide_root_dirname}/${slide_dirname}"
slide_full_path="${dir_full_path}/${slide_name}"

mkdir -p ${dir_full_path}
if !([ -f ${slide_full_path} ];) then
    cp ${slide_template_file} ${slide_full_path}
fi
echo ${slide_full_path}