* Re: [patch]: testsuite: run bash instead of sh when using brace expansion
[not found] ` <m3hai3kes8.fsf@redhat.com>
@ 2013-05-17 7:45 ` Christian Groessler
2013-05-17 8:13 ` Joel Brobecker
2013-05-17 16:44 ` Tom Tromey
0 siblings, 2 replies; 6+ messages in thread
From: Christian Groessler @ 2013-05-17 7:45 UTC (permalink / raw)
To: Sergio Durigan Junior; +Cc: gdb, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1753 bytes --]
On 05/16/13 01:24, Sergio Durigan Junior wrote:
> Next time, please make sure to send patches to
> gdb-patches@sourceware.org. Also I don't see you on gdb/MAINTAINERS,
> do you have copyright assignment for GDB? This patch is simple enough
> to go in without a copyright assignment, but if you intend to send
> more patches please let me know (in off) and I can get you started on
> the process.
I think I have an assignment for gdb, but I'm not 100 percent sure. I've
moved recently and don't find my papers at the moment.
Could someone verify please that the assignment is in place?
>> * gdb.dwarf2/dw2-dir-file-name.exp: Use bash instead of sh, since
>> brace expansion is not available in sh.
> ^^^^^^^^
> You're using spaces instead of a TAB here.
That was the result of copy-n-paste into the mail.
> I am not sure what others think, but instead of depending on bash (which
> may not be available on all platforms), I'd rather rewrite those
> commands to avoid brace expansions at all, thus making them compatible
> with sh. I am not a maintainer however, so you'd better wait for one
> until you do that.
How about the following patch? My tcl fu is not that strong, so I
explicitly wrote out
the expanded strings instead of computing them.
The shell command line could get quite long with this change, depending
how deep
the build directory is located in the hierarchy. I could invoke the
shell for each path separately, but
this would be slower. Any opinions?
regards,
chris
2013-05-17 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. Write out the expanded
names directly.
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 2549 bytes --]
Index: 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.dwarf2/dw2-dir-file-name.exp 15 Mar 2013 01:41:28 -0000 1.4
+++ gdb.dwarf2/dw2-dir-file-name.exp 16 May 2013 14:50:18 -0000
@@ -322,10 +322,64 @@ 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 { \
+ "" \
+ "/fdir" \
+ "/ldir" \
+ "/ldir/fdir" \
+ "/compdir" \
+ "/compdir/fdir" \
+ "/compdir/ldir" \
+ "/compdir/ldir/fdir" \
+ "/xdir" \
+ "/xdir/fdir" \
+ "/xdir/ldir" \
+ "/xdir/ldir/fdir" \
+ "/xdir/compdir" \
+ "/xdir/compdir/fdir" \
+ "/xdir/compdir/ldir" \
+ "/xdir/compdir/ldir/fdir" \
+ "/rdir" \
+ "/rdir/fdir" \
+ "/rdir/ldir" \
+ "/rdir/ldir/fdir" \
+ "/rdir/compdir" \
+ "/rdir/compdir/fdir" \
+ "/rdir/compdir/ldir" \
+ "/rdir/compdir/ldir/fdir" \
+ "/rdir/xdir" \
+ "/rdir/xdir/fdir" \
+ "/rdir/xdir/ldir" \
+ "/rdir/xdir/ldir/fdir" \
+ "/rdir/xdir/compdir" \
+ "/rdir/xdir/compdir/fdir" \
+ "/rdir/xdir/compdir/ldir" \
+}
+
+proc reverse {lst} {
+ set retlst {}
+ for {set i [expr "[llength $lst] - 1"]} {$i >= 0} {set i [expr "$i - 1"]} {
+ lappend retlst [lindex $lst $i]
+ }
+ return $retlst
+}
+
+proc pathexpand {prefix dirlst suffix} {
+ set retlst {}
+ for {set i 0} {$i < [llength $dirlst]} {incr i} {
+ lappend retlst "$prefix[lindex $dirlst $i]$suffix"
+ }
+ return $retlst
+}
+
+set filelist [pathexpand $srcabsdir $dirs "/$srctmpfile"]
+set dircreatelist [pathexpand $srcabsdir $dirs ""]
+set dirremovelist [pathexpand $srcabsdir [reverse $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}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch]: testsuite: run bash instead of sh when using brace expansion
2013-05-17 7:45 ` [patch]: testsuite: run bash instead of sh when using brace expansion Christian Groessler
@ 2013-05-17 8:13 ` Joel Brobecker
2013-05-17 16:44 ` Tom Tromey
1 sibling, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2013-05-17 8:13 UTC (permalink / raw)
To: Christian Groessler; +Cc: Sergio Durigan Junior, gdb, gdb-patches
> I think I have an assignment for gdb, but I'm not 100 percent sure.
> I've moved recently and don't find my papers at the moment.
> Could someone verify please that the assignment is in place?
I confirm I found you in the FSF records (all of binutils and GDB).
--
Joel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch]: testsuite: run bash instead of sh when using brace expansion
2013-05-17 7:45 ` [patch]: testsuite: run bash instead of sh when using brace expansion Christian Groessler
2013-05-17 8:13 ` Joel Brobecker
@ 2013-05-17 16:44 ` Tom Tromey
2013-05-17 22:57 ` Christian Groessler
1 sibling, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2013-05-17 16:44 UTC (permalink / raw)
To: Christian Groessler; +Cc: Sergio Durigan Junior, gdb, gdb-patches
>>>>> ">" == Christian Groessler <chris@groessler.org> writes:
>> How about the following patch? My tcl fu is not that strong, so I
>> explicitly wrote out the expanded strings instead of computing them.
You can do something like:
set dirs {}
foreach l {/ldir ""} {
foreach r {/rdir ""} {
... more foreaches here ...
lappend dirs [join [list $l $r $...]]
}
}
>> The shell command line could get quite long with this change,
>> depending how deep
>> the build directory is located in the hierarchy. I could invoke the
>> shell for each path separately, but
>> this would be slower. Any opinions?
If the result is too long we could batch it.
But I would not worry about it for now.
>> +proc reverse {lst} {
We have 'lreverse' in new Tcl, plus a compatibility proc in future.exp.
>> +proc pathexpand {prefix dirlst suffix} {
>> + set retlst {}
>> + for {set i 0} {$i < [llength $dirlst]} {incr i} {
>> + lappend retlst "$prefix[lindex $dirlst $i]$suffix"
>> + }
>> + return $retlst
foreach is more idiomatic.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch]: testsuite: run bash instead of sh when using brace expansion
2013-05-17 16:44 ` Tom Tromey
@ 2013-05-17 22:57 ` Christian Groessler
2013-05-20 15:16 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Christian Groessler @ 2013-05-17 22:57 UTC (permalink / raw)
To: Tom Tromey; +Cc: Sergio Durigan Junior, gdb, gdb-patches
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch]: testsuite: run bash instead of sh when using brace expansion
2013-05-17 22:57 ` Christian Groessler
@ 2013-05-20 15:16 ` Tom Tromey
2013-05-21 7:27 ` Christian Groessler
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2013-05-20 15:16 UTC (permalink / raw)
To: Christian Groessler; +Cc: Sergio Durigan Junior, gdb, gdb-patches
>>>>> ">" == Christian Groessler <chris@groessler.org> writes:
Just FYI - your patch got word-wrapped.
>> + lappend dirs [join [list $r$x$comp$l$f]]
My suggestion for "join" was really odd. I was confused...
It is simpler to just use string concatenation like
lappend dirs $r$x$comp$l$f
The patch is ok with that change.
thanks,
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch]: testsuite: run bash instead of sh when using brace expansion
2013-05-20 15:16 ` Tom Tromey
@ 2013-05-21 7:27 ` Christian Groessler
0 siblings, 0 replies; 6+ messages in thread
From: Christian Groessler @ 2013-05-21 7:27 UTC (permalink / raw)
To: Tom Tromey; +Cc: Sergio Durigan Junior, gdb, gdb-patches
On 05/20/13 17:16, Tom Tromey wrote:
>
>> lappend dirs [join [list $r$x$comp$l$f]]
> My suggestion for "join" was really odd. I was confused...
> It is simpler to just use string concatenation like
>
> lappend dirs $r$x$comp$l$f
>
> The patch is ok with that change.
Committed.
Thanks,
chris
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-21 7:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <51936596.8010205@groessler.org>
[not found] ` <m3hai3kes8.fsf@redhat.com>
2013-05-17 7:45 ` [patch]: testsuite: run bash instead of sh when using brace expansion Christian Groessler
2013-05-17 8:13 ` Joel Brobecker
2013-05-17 16:44 ` Tom Tromey
2013-05-17 22:57 ` Christian Groessler
2013-05-20 15:16 ` Tom Tromey
2013-05-21 7:27 ` Christian Groessler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox