[67300de] | 1 | Submitted By: Tushar Teredesai <tushar@linuxfromscratch.org>
|
---|
| 2 | Date: 2005-07-25
|
---|
| 3 | Initial Package Version: 1.5
|
---|
| 4 | Upstream Status: Sent, no response yet.
|
---|
| 5 | Origin: http://archive.linuxfromscratch.org/mail-archives/lfs-dev/2003-April/033602.html
|
---|
| 6 | http://archive.linuxfromscratch.org/mail-archives/lfs-dev/2003-June/035234.html
|
---|
| 7 | http://linuxfromscratch.org/pipermail/lfs-dev/2005-June/051908.html
|
---|
| 8 | Description: Add tempfile wrapper script. Use "make install-tempfile" to install it.
|
---|
| 9 |
|
---|
| 10 | diff -Naur mktemp-1.5.orig/Makefile.in mktemp-1.5/Makefile.in
|
---|
| 11 | --- mktemp-1.5.orig/Makefile.in 2003-03-23 18:09:56.000000000 -0700
|
---|
| 12 | +++ mktemp-1.5/Makefile.in 2005-07-25 11:11:11.000000000 -0600
|
---|
| 13 | @@ -113,6 +113,9 @@
|
---|
| 14 | install-man:
|
---|
| 15 | $(INSTALL) -m 0444 $(srcdir)/$(PROG).$(mantype) $(mandir)/man1/$(PROG).1
|
---|
| 16 |
|
---|
| 17 | +install-tempfile: $(srcdir)/tempfile
|
---|
| 18 | + $(INSTALL) -m 0555 $(srcdir)/tempfile $(bindir)/tempfile
|
---|
| 19 | +
|
---|
| 20 | check:
|
---|
| 21 | @echo nothing to check
|
---|
| 22 |
|
---|
| 23 | diff -Naur mktemp-1.5.orig/tempfile mktemp-1.5/tempfile
|
---|
| 24 | --- mktemp-1.5.orig/tempfile 1969-12-31 17:00:00.000000000 -0700
|
---|
| 25 | +++ mktemp-1.5/tempfile 2005-07-25 11:13:41.000000000 -0600
|
---|
| 26 | @@ -0,0 +1,85 @@
|
---|
| 27 | +#!/bin/bash
|
---|
| 28 | +# A tempfile wrapper for mktemp
|
---|
| 29 | +# Note: If you can, avoid using tempfile and use mktemp instead.
|
---|
| 30 | +# This wrapper is provided for compatibility since some scripts use
|
---|
| 31 | +# tempfile. If possible, the best solution is to patch the scripts
|
---|
| 32 | +# to use mktemp.
|
---|
| 33 | +#
|
---|
| 34 | +# Copyright (c) Tushar Teredesai <tush@yahoo.com>
|
---|
| 35 | +#
|
---|
| 36 | +# Permission to use, copy, modify, and distribute this software for any
|
---|
| 37 | +# purpose with or without fee is hereby granted, provided that the above
|
---|
| 38 | +# copyright notice and this permission notice appear in all copies.
|
---|
| 39 | +#
|
---|
| 40 | +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
---|
| 41 | +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
---|
| 42 | +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
---|
| 43 | +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
---|
| 44 | +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
---|
| 45 | +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
---|
| 46 | +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
---|
| 47 | +#
|
---|
| 48 | +
|
---|
| 49 | +# Usage info
|
---|
| 50 | +usage()
|
---|
| 51 | +{
|
---|
| 52 | + echo "Usage: tempfile [OPTION]"
|
---|
| 53 | + echo
|
---|
| 54 | + echo "Create a temporary file in a safe manner."
|
---|
| 55 | + echo "This version is a wrapper that invokes mktemp."
|
---|
| 56 | + echo "NOTE: Do not use tempfile in your scripts."
|
---|
| 57 | + echo " Use mktemp instead."
|
---|
| 58 | + echo
|
---|
| 59 | + echo "[-d|--directory] DIR -> place temporary file in DIR"
|
---|
| 60 | + echo "[-p|--prefix] PREFIX -> ignored"
|
---|
| 61 | + echo "[-s|--suffix] SUFFIX -> ignored"
|
---|
| 62 | + echo "[-n|--name] NAME -> ignored"
|
---|
| 63 | + echo "[-m|--mode] MODE -> ignored"
|
---|
| 64 | + echo "--version -> output version information and exit"
|
---|
| 65 | +}
|
---|
| 66 | +
|
---|
| 67 | +# parse all arguments
|
---|
| 68 | +while [ $# != 0 ]
|
---|
| 69 | +do
|
---|
| 70 | + case "$1" in
|
---|
| 71 | + # -d for tempfile is equivalent to -p for mktemp
|
---|
| 72 | + -d|--directory)
|
---|
| 73 | + dir="$2"
|
---|
| 74 | + shift 2
|
---|
| 75 | + ;;
|
---|
| 76 | + --directory=*)
|
---|
| 77 | + dir="${1#--directory=}"
|
---|
| 78 | + shift 1
|
---|
| 79 | + ;;
|
---|
| 80 | + -d*)
|
---|
| 81 | + dir="${1#-d}"
|
---|
| 82 | + shift 1
|
---|
| 83 | + ;;
|
---|
| 84 | + # The following switches are ignored.
|
---|
| 85 | + -p|--prefix|-s|--suffix|-n|--name|-m|--mode)
|
---|
| 86 | + shift 2
|
---|
| 87 | + ;;
|
---|
| 88 | + -p*|--prefix=*|-s*|--suffix=*|-n*|--name=*|-m*|--mode=*)
|
---|
| 89 | + shift 1
|
---|
| 90 | + ;;
|
---|
| 91 | + # --version for tempfile is equivalent to -V for mktemp
|
---|
| 92 | + --version)
|
---|
| 93 | + echo "tempfile 1.0 (`mktemp -V 2>/dev/null`)"
|
---|
| 94 | + exit 0
|
---|
| 95 | + ;;
|
---|
| 96 | + # Unknown switch
|
---|
| 97 | + *)
|
---|
| 98 | + usage
|
---|
| 99 | + exit 1
|
---|
| 100 | + ;;
|
---|
| 101 | + esac
|
---|
| 102 | +done
|
---|
| 103 | +
|
---|
| 104 | +# Use the dir if $TMPDIR is not set.
|
---|
| 105 | +if [ -z "$TMPDIR" -a ! -z "$dir" ]
|
---|
| 106 | +then
|
---|
| 107 | + export TMPDIR="$dir"
|
---|
| 108 | +fi
|
---|
| 109 | +# Execute mktemp with proper arguments
|
---|
| 110 | +# the -t behaviour of mktemp is the default for tempfile
|
---|
| 111 | +exec mktemp -t
|
---|