X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Fpsize.sh;h=c4d73e1ad0f403b06957f80af1e9905d0beae4c6;hb=f73dda092b33638d2d5e9c35375f687a607b5403;hp=2c874f551fac87d18a4b131db8996638801a99e0;hpb=28ef6c316f1aff914bb95ac09787a3c83c1815fd;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/psize.sh b/builtins/psize.sh old mode 100755 new mode 100644 index 2c874f5..c4d73e1 --- a/builtins/psize.sh +++ b/builtins/psize.sh @@ -4,10 +4,18 @@ # pipesize.h so ulimit.c can use it. : ${TMPDIR:=/tmp} -TMPNAME=pipsize.$$ -TMPFILE=$TMPDIR/$TMPNAME +# try to use mktemp(1) if the system supports it +{ TMPFILE="`mktemp $TMPDIR/pipsize.XXXXXX 2>/dev/null`"; } 2>/dev/null +used_mktemp=true -trap 'rm -f $TMPFILE' 0 1 2 3 6 15 +if [ -z "$TMPFILE" ]; then + TMPNAME=pipsize.$$ + TMPFILE=$TMPDIR/$TMPNAME + used_mktemp=false +fi + +trap 'rm -f "$TMPFILE" ; exit 1' 1 2 3 6 15 +trap 'rm -f "$TMPFILE"' 0 echo "/*" echo " * pipesize.h" @@ -21,14 +29,15 @@ echo "" # Try to avoid tempfile races. We can't really check for the file's # existance before we run psize.aux, because `test -e' is not portable, # `test -h' (test for symlinks) is not portable, and `test -f' only -# checks for regular files +# checks for regular files. If we used mktemp(1), we're ahead of the +# game. # -rm -f $TMPFILE +$used_mktemp || rm -f "$TMPFILE" -./psize.aux 2>$TMPFILE | sleep 3 +./psize.aux 2>"$TMPFILE" | sleep 3 -if [ -s $TMPFILE ]; then - echo "#define PIPESIZE `cat $TMPFILE`" +if [ -s "$TMPFILE" ]; then + echo "#define PIPESIZE `cat "$TMPFILE"`" else echo "#define PIPESIZE 512" fi