1#!/usr/bin/env bash 2 3# Various shell functions used in some of the Makefiles and other 4# scripts included with CoCoALib. 5 6# Copyright 2006 John Abbott. 7# You are free to use any part of this code in your own programs. 8 9 10mktempdir() 11{ 12 TODAY=`date "+%Y%m%d"` 13 TIME=`date "+%H%M%S"` 14 TMP_DIR="/tmp/CoCoALib-config/$USER-$TODAY/$1-$TIME-$$" 15 /bin/rm -rf "$TMP_DIR" && /bin/mkdir -p "$TMP_DIR" 16 if [ $? -ne 0 ] 17 then 18 echo "ERROR: failed to create temporary directory \"$TMP_DIR\" $SCRIPT_NAME" > /dev/stderr 19 exit 1 20 fi 21 echo "$TMP_DIR" 22} 23 24 25echounderline() 26{ 27 echo "$*" 28 echo "$*" | tr "\040-\377" "[-*]" 29} 30 31echobox() 32{ 33 mesg=">>>> $* <<<<" 34 dashes=`echo "$mesg" | tr "\040-\377" "[-*]"` 35 echo "$dashes" 36 echo "$mesg" 37 echo "$dashes" 38} 39 40echoerror() 41{ 42 mesg=">>>>> $* <<<<<" 43 equals=`echo "$mesg" | tr "\040-\377" "[=*]"` 44 echo "$equals" 45 echo "$mesg" 46 echo "$equals" 47} 48