1# mktemp 2 3# Copyright (c) Derek Price, Ximbiot <http://ximbiot.com>, and the 4# Free Software Foundation, Inc. <http://gnu.org> 5 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2, or (at your option) 9# any later version. 10 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19# 02111-1307, USA. 20 21 22 23# This Bourne Shell scriptlet is intended as a simple replacement for 24# the BSD mktemp function for systems that do not support mktemp. It 25# currently does not check that the files it is creating did not exist 26# previously and it does not verify that it successfully creates the 27# files it returns the names of. 28mktemp() { 29 if test x"$1" = x-d; then 30 tmp=`echo $2 |sed "s/XXXXXX/$$/"` 31 (umask 077 && exec mkdir $tmp) || return 1 32 else 33 tmp=`echo $1 |sed "s/XXXXXX/$$/"` 34 (umask 077 && touch $tmp) || return 1 35 fi 36 echo $tmp 37 return 0 38} 39 40