xref: /potrace-1.14/check/missing.sh (revision b3fce824)
1#! /bin/sh
2
3# Copyright (C) 2001-2017 Peter Selinger.
4# This file is free software and it is covered by the GNU general
5# public license. See the file COPYING for details.
6
7# provide (dumb) replacements for missing functions
8
9# first, because the "which" command on Solaris is totally useless,
10# we need to implement our own. This code is adapted from autoconf.
11
12my_which () {
13    if test "$#" -ne 1; then
14	echo "my_which: wrong number of arguments" >&2
15	return 255
16    fi
17    cmd="$1"
18    IFS="${IFS=   }"; save_ifs="$IFS"; IFS=":"
19    path="$PATH"
20    for dir in $path; do
21	test -z "$dir" && dir=.
22	if test -f "$dir/$cmd"; then
23	    echo "$dir/$cmd"
24	    IFS="$save_ifs"
25	    return 0
26	fi
27    done
28    IFS="$save_ifs"
29    return 1
30}
31
32# "mktemp" replacement: note that this creates the same filename each time.
33# Thus, when creating more than one tempfile, must give different templates.
34
35MKTEMP=`my_which mktemp`
36if test -z "$MKTEMP"; then
37    echo "Warning: the mktemp program is missing. Using a dummy replacement." >&2
38    mktemp () {
39	echo "$1" | sed -e "s/XXXXXX/$$/"
40    }
41fi
42
43
44