Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix `trap` in a few shell scripts
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 20 Sep 2022 16:50:16 +0000 (18:50 +0200)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 20 Sep 2022 16:50:16 +0000 (18:50 +0200)
The original `trap` lines in these scripts are incomplete: in case of
any signal, they delete the working directory but let the script run to
completion, which is useless because it will only proceed to complain
about the working directory being removed.  Add `exit` there, with the
original exit value (not rm's).

Since this is mostly just cosmetic, no backpatch.

Discussion: https://postgr.es/m/20220913181002.hzsosy7qkemb7ky7@alvherre.pgsql

src/tools/find_static
src/tools/make_ctags
src/tools/pginclude/cpluspluscheck
src/tools/pginclude/headerscheck
src/tools/pgtest

index 1cc9ec3b3dc60333682f554c3e4adaac19c9613b..b75930251d9604ff27353bb3351e7b541afc389b 100755 (executable)
@@ -2,7 +2,7 @@
 
 # src/tools/find_static
 
-trap "rm -f /tmp/$$" 0 1 2 3 15
+trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
 
 # This script finds functions that are either never called, or
 # should be static.
index d8d18d1569f984d85e526b99a6e40172797b0132..912b6fafac1326f6fe13687bde8407180a0ecf63 100755 (executable)
@@ -5,7 +5,7 @@
 command -v ctags >/dev/null || \
    { echo "'ctags' program not found" 1>&2; exit 1; }
 
-trap "rm -f /tmp/$$" 0 1 2 3 15
+trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
 rm -f ./tags
 
 IS_EXUBERANT=""
index bffca18890c2000c804d8d9c23ebdaf7cf8d5a1b..b393f2a2eaa5552e3a7ac654b09caf15cbf7933b 100755 (executable)
@@ -50,7 +50,7 @@ done
 # Create temp directory.
 tmp=`mktemp -d /tmp/$me.XXXXXX`
 
-trap 'rm -rf $tmp' 0 1 2 3 15
+trap "ret=$?; rm -rf $tmp; exit $ret" 0 1 2 3 15
 
 exit_status=0
 
index bd45ee5e5c7574ab0fa9383b0a6b2c1fb2e11be1..2a39856f88c8a1fb308956b7fcb01e3e14971f55 100755 (executable)
@@ -46,7 +46,7 @@ CPPFLAGS=`echo "$CPPFLAGS" | sed "s|\\\$(PG_SYSROOT)|$PG_SYSROOT|g"`
 # Create temp directory.
 tmp=`mktemp -d /tmp/$me.XXXXXX`
 
-trap 'rm -rf $tmp' 0 1 2 3 15
+trap "ret=$?; rm -rf $tmp; exit $ret" 0 1 2 3 15
 
 exit_status=0
 
@@ -154,9 +154,9 @@ do
        EXTRAINCLUDES="$python_includespec" ;;
        src/interfaces/ecpg/*)
        EXTRAINCLUDES="-I $builddir/src/interfaces/ecpg/include -I $srcdir/src/interfaces/ecpg/include" ;;
-       src/backend/parser/*)
+       src/backend/parser/*)
        EXTRAINCLUDES="-I $builddir/src/backend/parser/" ;;
-       src/backend/utils/adt/*)
+       src/backend/utils/adt/*)
        EXTRAINCLUDES="-I $builddir/src/backend/utils/adt/" ;;
        *)
        EXTRAINCLUDES="" ;;
index 70f6a62ad02e404427771a485ed89ce931c2cf8d..fa665ff8172f5e0565491e604e449c1af2137822 100755 (executable)
@@ -14,7 +14,7 @@ MAKE="make"
 
 [ ! -d src ] && echo "This must be run from the top of the PostgreSQL source tree" 1>&2 && exit 1
 
-trap "rm -rf /tmp/$$" 0 1 2 3 15
+trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
 mkdir /tmp/$$
 TMP="/tmp/$$"