This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch]: testsuite: run bash instead of sh when using brace expansion
- From: Christian Groessler <chris at groessler dot org>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Sergio Durigan Junior <sergiodj at redhat dot com>, gdb at sourceware dot org, gdb-patches at sourceware dot org
- Date: Sat, 18 May 2013 00:57:14 +0200
- Subject: Re: [patch]: testsuite: run bash instead of sh when using brace expansion
- References: <51936596 dot 8010205 at groessler dot org> <m3hai3kes8 dot fsf at redhat dot com> <5195E023 dot 10203 at groessler dot org> <87a9ntr1xl dot fsf at fleche dot redhat dot com>
Hi Tom,
On 05/17/13 18:44, Tom Tromey wrote:
You can do something like:
set dirs {}
foreach l {/ldir ""} {
foreach r {/rdir ""} {
... more foreaches here ...
lappend dirs [join [list $l $r $...]]
}
}
...
We have 'lreverse' in new Tcl, plus a compatibility proc in future.exp.
...
foreach is more idiomatic.
Thanks for the tips.
Here's an updated patch:
2013-05-18 Christian Groessler <chris@groessler.org>
* gdb.dwarf2/dw2-dir-file-name.exp: Don't use brace expansion,
since it's not supported in all shells.
Index: gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp,v
retrieving revision 1.4
diff -u -p -r1.4 dw2-dir-file-name.exp
--- gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp 15 Mar 2013
01:41:28 -0000 1.4
+++ gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp 17 May 2013
22:47:20 -0000
@@ -322,10 +322,35 @@ if { [gdb_compile "${asmsrcfile} ${srcdi
return -1
}
-remote_exec host "sh -c \"rm -f
${srcabsdir}{/rdir,}{/xdir,}{/compdir,}{/ldir,}{/fdir,}/${srctmpfile}\""
-remote_exec host "sh -c \"rmdir
${srcabsdir}{/rdir,}{/xdir,}{/compdir,}{/ldir,}{/fdir,}\""
-remote_exec host "sh -c \"mkdir
${srcabsdir}{,/rdir}{,/xdir}{,/compdir}{,/ldir}{,/fdir}\""
-remote_exec host "sh -c \"for d in
${srcabsdir}{,/rdir}{,/xdir}{,/compdir}{,/ldir}{,/fdir};do cp
${srcdir}/${subdir}/${srcfile} \\\$d/${srctmpfile}; done\""
+set dirs {}
+foreach r {"" /rdir} {
+ foreach x {"" /xdir} {
+ foreach comp {"" /compdir} {
+ foreach l {"" /ldir} {
+ foreach f {"" /fdir} {
+ lappend dirs [join [list $r$x$comp$l$f]]
+ }
+ }
+ }
+ }
+}
+
+proc pathexpand {prefix dirlst suffix} {
+ set retlst {}
+ foreach dir $dirlst {
+ lappend retlst "$prefix$dir$suffix"
+ }
+ return $retlst
+}
+
+set filelist [pathexpand $srcabsdir $dirs "/$srctmpfile"]
+set dircreatelist [pathexpand $srcabsdir $dirs ""]
+set dirremovelist [pathexpand $srcabsdir [lreverse $dirs] ""]
+
+remote_exec host "sh -c \"rm -f $filelist\""
+remote_exec host "sh -c \"rmdir $dirremovelist\""
+remote_exec host "sh -c \"mkdir $dircreatelist\""
+remote_exec host "sh -c \"for d in $dircreatelist; do cp
${srcdir}/${subdir}/${srcfile} \\\$d/${srctmpfile}; done\""
clean_restart ${testfile}
Ok to install?
regards,
chris