This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: rename to `insight'


> From: Tom Tromey <tromey@cygnus.com>
> Date: 28 Nov 2000 15:13:56 -0700
> 
> Instead of a pure rename, I came up with the appended patch.  If
> Insight is enabled, this will create a small shell script named
> `insight' which will run insight.

I would suggest to consider a short C program instead of a shell
script, for portability's sake.  Shell scripts are not very portable
to non-Posix platforms.  See below.

> --- Makefile.in	2000/11/10 23:02:56	1.47
> +++ Makefile.in	2000/11/28 21:59:12
> @@ -1308,7 +1314,7 @@
>  # FIXME: cagney/2000-03-27: Post 5.0 this link code can be removed.
>  # It should now be possible to run GDBtk from the build directory
>  # without the link in place.
> -all-gdbtk:
> +all-gdbtk: insight
>  	@if test ! -d gdbtcl/images ; then \
>  	  if test "$(LN_S)" = "ln -s" ; then \
>  	    echo linking ${srcdir}/gdbtk/library to gdbtcl ; \
> @@ -1334,11 +1340,32 @@
>  	$(SHELL) $(srcdir)/../mkinstalldirs $(datadir)/gdbtcl/help \
>  		$(datadir)/gdbtcl/help/images \
>  		$(datadir)/gdbtcl/help/trace ; \
> +	$(SHELL) $(srcdir)/../mkinstalldirs $(bindir)

Shouldn't this say "-$(SHELL)", in case $(bindir) already exists?

> +insight: $(srcdir)/insight.in
> +	transformed_name=`t='$(program_transform_name)'; \
> +			  echo gdb | sed -e $$t` ; \
> +	if test "x$$transformed_name" = x; then \
> +	  transformed_name=gdb ; \
> +	else \
> +	  true ; \
> +	fi ; \
> +	sed -e "s,\@gdb\@,$$transformed_name," -e 's,\@bindir\@,$(bindir),' \
> +	  < $(srcdir)/insight.in > insight \
> +	  && chmod +x insight

This assumes that the distribution is not moved once installed.  That
might be true on a typical Unix system (even there you might have
problems with CD-ROM distributions), but it will make lots of problems
on DOS/Windows systems, where a precompiled binary is usually
installed into a directory that has nothing to do with the original
installation at "make install" time.

Why not simply invoke "gdb" and let PATH do its thing?  Or at least
try that before falling back on the installation directory?

> +# Try to pick up gdb from the same directory as insight.
> +path="`echo $0 | sed -e 's,/[^/]*$,,'`"

This doesn't work with DOS/Windows-style file names with backslashes.

> +if test -n "$path"; then
> +   exe="$path/$gdb"
> +else
> +   exe="$bindir/$gdb"
> +fi
> +exec $exe -w ${1+"$@"}

I'm not sure this will DTRT with all DOS/Windows ports of Unixy
shells.  I suggest to use "gdb.exe" on those platfrms (better safe
than sorry).

Writing a short C program would eliminate all these problems (and also
avoid requiring users to have a ported shell on their machines).
That's why I suggested that in the first place.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]