]> git.ipfire.org Git - thirdparty/bash.git/blame - builtins/psize.sh
Imported from ../bash-2.04.tar.gz.
[thirdparty/bash.git] / builtins / psize.sh
CommitLineData
726f6388
JA
1#! /bin/sh
2#
3# psize.sh -- determine this system's pipe size, and write a define to
4# pipesize.h so ulimit.c can use it.
5
bb70624e 6: ${TMPDIR:=/tmp}
cce855bc
JA
7TMPNAME=pipsize.$$
8TMPFILE=$TMPDIR/$TMPNAME
9
10trap 'rm -f $TMPFILE' 0 1 2 3 6 15
11
726f6388
JA
12echo "/*"
13echo " * pipesize.h"
14echo " *"
15echo " * This file is automatically generated by psize.sh"
16echo " * Do not edit!"
17echo " */"
18echo ""
19
cce855bc
JA
20#
21# Try to avoid tempfile races. We can't really check for the file's
22# existance before we run psize.aux, because `test -e' is not portable,
23# `test -h' (test for symlinks) is not portable, and `test -f' only
24# checks for regular files
25#
26rm -f $TMPFILE
27
28./psize.aux 2>$TMPFILE | sleep 3
726f6388 29
cce855bc
JA
30if [ -s $TMPFILE ]; then
31 echo "#define PIPESIZE `cat $TMPFILE`"
726f6388
JA
32else
33 echo "#define PIPESIZE 512"
34fi
35
726f6388 36exit 0