public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/testsuite] Clean up gdb/contrib/expect-read1.sh
@ 2024-06-15  6:10 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2024-06-15  6:10 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=486df2b7c88e3a08d3d799b1595b5fd0dce41d6f

commit 486df2b7c88e3a08d3d799b1595b5fd0dce41d6f
Author: Tom de Vries <tdevries@suse.de>
Date:   Sat Jun 15 08:10:44 2024 +0200

    [gdb/testsuite] Clean up gdb/contrib/expect-read1.sh
    
    Clean up script gdb/contrib/expect-read1.sh by:
    - fixing shellcheck warnings,
    - using mktemp (which takes TMPDIR into account) instead of a hardcoded
      "/tmp/expect-read1.$$.so",
    - adding comments, and
    - adding emacs / vi settings for local tab size 2 (copied from ./ltmain.sh).
    
    Tested on x86_64-linux.
    
    Approved-by: Kevin Buettner <kevinb@redhat.com>

Diff:
---
 gdb/contrib/expect-read1.sh | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/gdb/contrib/expect-read1.sh b/gdb/contrib/expect-read1.sh
index 890a1cdbd07..82c638c59d2 100755
--- a/gdb/contrib/expect-read1.sh
+++ b/gdb/contrib/expect-read1.sh
@@ -26,17 +26,32 @@
 # or
 # bash$ EXPECT=../contrib/expect-read1.sh runtest
 
-C=`echo $0|sed 's/\.sh$/.c/'`
-if ! test -e $C; then
+# Find source file.
+C=$(echo "$0" | sed 's/\.sh$/.c/')
+if ! test -e "$C"; then
   echo >&2 "$0: Cannot find 'srcdir/gdb/contrib/expect-read1.c' at '$C'."
   exit 2
 fi
-SO=/tmp/expect-read1.$$.so
-rm -f $SO
+
+# Create temp directory.
+tmpdir=$(mktemp -d)
+
+# Schedule cleanup.
+trap 'rm -rf $tmpdir' EXIT
+
+# Compile shared library.
+SO=$tmpdir/expect-read1.so
 CMD="${CC_FOR_TARGET:-gcc} -o $SO -Wall -fPIC -shared $C"
 if ! $CMD; then
   echo >&2 "$0: Failed: $CMD"
   exit 2
 fi
-trap "rm -f $SO" EXIT
+
+# Call expect with the shared library preloaded.
 LD_PRELOAD=$SO expect "$@"
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-15  6:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-15  6:10 [binutils-gdb] [gdb/testsuite] Clean up gdb/contrib/expect-read1.sh Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).