threads / patch / 3531

patch, 3 partscg-mv doesn't work with bash 3.1.7 due to excessive quotes

Subject: [PATCH 1/3] cg-mv doesn't work with bash 3.1.7 due to excessive quotes

## tl;dr

8 messages between Mar 3, 2006 and Mar 19, 2006. Diffs are folded; open one to read it.

replies: 7people: 4as markdown or json

Pavel Roskin· Mar 3, 2006, 01:11 UTC · lore
Signed-off-by: Pavel Roskin <proski@gnu.org>
---
 cg-mv |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to cg-mv +1 −1
diff --git a/cg-mv b/cg-mv
index c42853c..d5618ba 100755
--- a/cg-mv
+++ b/cg-mv
@@ -38,7 +38,7 @@ done
 # Strip trailing / which is something GIT does not bear well.
 ARGS2=()
 for arg in "${ARGS[@]}"; do
-	ARGS2["${#ARGS2[@]}"]="$_git_relpath${arg%/}"
+	ARGS2[${#ARGS2[@]}]="$_git_relpath${arg%/}"
 done
 
 git-mv $force "${ARGS2[@]}"
Pavel Roskin· Mar 3, 2006, 01:11 UTC · re: Pavel Roskin · lore

[PATCH 2/3] Make tutorial-script work with current cogito

Labels on merge conflict lines have changed. There is no "git rename", use cg-mv instead. In one case stack.h is not created, so copy stack.h~master to stack.h before fixing it.

Also fix comments in script.sh to use the new labels.
Signed-off-by: Pavel Roskin <proski@gnu.org>
---
 .../tutorial-script/0010-alice-bob-fixup.ed        |    2 +
 .../tutorial-script/0017-alice-bob-fixup.ed        |    2 +
 .../tutorial-script/0018-alice-charlie-fixup1.ed   |    4 +--
 .../tutorial-script/0019-alice-charlie-fixup2.ed   |    4 +--
 .../tutorial-script/0021-bob-alice-fixup1.ed       |    4 +--
 .../tutorial-script/0022-bob-alice-fixup2.ed       |    2 +
 Documentation/tutorial-script/script.sh            |   31 ++++++++++----------
 7 files changed, 25 insertions(+), 24 deletions(-)
Show changes to 7 files +25 −24

Documentation/tutorial-script/0010-alice-bob-fixup.ed, Documentation/tutorial-script/0017-alice-bob-fixup.ed, Documentation/tutorial-script/0018-alice-charlie-fixup1.ed, Documentation/tutorial-script/0019-alice-charlie-fixup2.ed, Documentation/tutorial-script/0021-bob-alice-fixup1.ed, Documentation/tutorial-script/0022-bob-alice-fixup2.ed, Documentation/tutorial-script/script.sh

diff --git a/Documentation/tutorial-script/0010-alice-bob-fixup.ed b/Documentation/tutorial-script/0010-alice-bob-fixup.ed
index ca2047c..81b1360 100644
--- a/Documentation/tutorial-script/0010-alice-bob-fixup.ed
+++ b/Documentation/tutorial-script/0010-alice-bob-fixup.ed
@@ -1,3 +1,3 @@
-/^<<<<<<< rpn\.c/,/^>>>>>>> \.merge_file_/d
+/^<<<<<<< bob/,/^>>>>>>> bobswork/d
 w
 q
diff --git a/Documentation/tutorial-script/0017-alice-bob-fixup.ed b/Documentation/tutorial-script/0017-alice-bob-fixup.ed
index ad04eb7..6353328 100644
--- a/Documentation/tutorial-script/0017-alice-bob-fixup.ed
+++ b/Documentation/tutorial-script/0017-alice-bob-fixup.ed
@@ -1,4 +1,4 @@
-/^<<<<<<< Makefile/d
+/^<<<<<<< \.merge_file_/d
 /^=======/,/^=======/+1d
 /^>>>>>>> \.merge_file_/d
 w
diff --git a/Documentation/tutorial-script/0018-alice-charlie-fixup1.ed b/Documentation/tutorial-script/0018-alice-charlie-fixup1.ed
index 65f5ef5..20c25c8 100644
--- a/Documentation/tutorial-script/0018-alice-charlie-fixup1.ed
+++ b/Documentation/tutorial-script/0018-alice-charlie-fixup1.ed
@@ -1,7 +1,7 @@
-/^<<<<<<< Makefile/d
+/^<<<<<<< master/d
 /^rpn\.o:/s/\.h.*$/.h lexer.h/
 /^lexer\.o:/s/:.*$/: lexer.h/
-/^=======/,/^>>>>>>> \.merge_file_/d
+/^=======/,/^>>>>>>> charlie/d
 w
 q
 
diff --git a/Documentation/tutorial-script/0019-alice-charlie-fixup2.ed b/Documentation/tutorial-script/0019-alice-charlie-fixup2.ed
index f1aadb4..5d531de 100644
--- a/Documentation/tutorial-script/0019-alice-charlie-fixup2.ed
+++ b/Documentation/tutorial-script/0019-alice-charlie-fixup2.ed
@@ -1,5 +1,5 @@
-/^<<<<<<< rpn\.c/,/^=======/d
-/^>>>>>>> \.merge_file_/d
+/^<<<<<<< master/,/^=======/d
+/^>>>>>>> charlie/d
 w
 q
 
diff --git a/Documentation/tutorial-script/0021-bob-alice-fixup1.ed b/Documentation/tutorial-script/0021-bob-alice-fixup1.ed
index 2783f73..df703d5 100644
--- a/Documentation/tutorial-script/0021-bob-alice-fixup1.ed
+++ b/Documentation/tutorial-script/0021-bob-alice-fixup1.ed
@@ -1,4 +1,4 @@
-/^<<<<<<< Makefile/,/^=======/d
-/^>>>>>>> \.merge_file_/d
+/^<<<<<<< master/,/^=======/d
+/^>>>>>>> origin/d
 w
 q
diff --git a/Documentation/tutorial-script/0022-bob-alice-fixup2.ed b/Documentation/tutorial-script/0022-bob-alice-fixup2.ed
index 18c90d4..d8c5746 100644
--- a/Documentation/tutorial-script/0022-bob-alice-fixup2.ed
+++ b/Documentation/tutorial-script/0022-bob-alice-fixup2.ed
@@ -1,5 +1,5 @@
 /^#include "stack\.h"/+1d
 /^#include "lexer\.h"/+1,/^#include "stack\.h"/d
-/^<<<<<<< rpn\.c/-1,/^>>>>>>> \.merge_file_/d
+/^<<<<<<< master/-1,/^>>>>>>> origin/d
 w
 q
diff --git a/Documentation/tutorial-script/script.sh b/Documentation/tutorial-script/script.sh
index bc70b77..edcebda 100755
--- a/Documentation/tutorial-script/script.sh
+++ b/Documentation/tutorial-script/script.sh
@@ -120,13 +120,13 @@ cg-update bobswork && should_fail
 # difference between her version and Bob's:
 
 #: ...
-#: <<<<<<< rpn.c
+#: <<<<<<< bob
 #: extern double pop(void);
 #: extern void push(double);
 #: extern void clear(void);
 #: 
 #: =======
-#: >>>>>>> .merge_file_5wCNZT
+#: >>>>>>> bobswork
 #: extern int getsym(void);
 #: ...
  
@@ -216,7 +216,7 @@ cg-merge bob && should_fail
 # Merge fails:
 
 #: ...
-#: <<<<<<< Makefile
+#: <<<<<<< .merge_file_l54ztH
 #:	$(CC) $(CFLAGS) $^ -lm -o $@
 #: =======
 #:	$(CC) $(CFLAGS) $^ -o $@
@@ -235,31 +235,31 @@ cg-merge charlie && should_fail
 # Merge conflicts!
 
 #: ...
-#: <<<<<<< Makefile
-#:         $(CC) $(CFLAGS) $^ -lm -o $@
-#:        
+#: <<<<<<< master
+#:	$(CC) $(CFLAGS) $^ -lm -o $@
+#:	
 #: rpn.o: stack.h
 #: stack.o: stack.h
-#: lexer.o:
+#: lexer.o:	
 #: =======
-#:         $(CC) $(CFLAGS) $^ -o $@
-#:                
+#:	$(CC) $(CFLAGS) $^ -o $@
+#:	
 #: rpn.o lexer.o: lexer.h
-#: 
-#: >>>>>>> .merge_file_huuX9C
+#:	
+#: >>>>>>> charlie
 
 ed Makefile < $TOP/0018-alice-charlie-fixup1.ed
 
 #: ...
-#: <<<<<<< rpn.c
+#: <<<<<<< master
 #: extern int getsym(void);
 #: 
 #: =======
 #: extern double pop(void);
 #: extern void push(double);
 #: extern void clear(void);
-#:
-#: >>>>>> .merge_file_qtv6VA
+#: 
+#: >>>>>>> charlie
 #: ...
 
 ed rpn.c    < $TOP/0019-alice-charlie-fixup2.ed
@@ -273,7 +273,7 @@ cg-add CONTRIBUTORS
 cg-commit -m "Add CONTRIBUTORS"
 
 # Wrong file name...
-git rename CONTRIBUTORS CREDITS
+cg-mv CONTRIBUTORS CREDITS
 cg-commit -m "Rename CONTRIBUTORS to CREDITS"
 
 
@@ -308,6 +308,7 @@ echo "Merge with 0.4" | cg-merge && shou
 # Mishandled stack.h
 ed Makefile < $TOP/0021-bob-alice-fixup1.ed
 ed rpn.c    < $TOP/0022-bob-alice-fixup2.ed
+cp stack.h~master stack.h
 ed stack.h  < $TOP/0023-bob-alice-fixup3.ed
 cg-add stack.h
 
Petr Baudis· Mar 19, 2006, 22:37 UTC · re: Pavel Roskin · lore

Re: [PATCH 2/3] Make tutorial-script work with current cogito

Dear diary, on Fri, Mar 03, 2006 at 02:11:57AM CET, I got a letter where Pavel Roskin <proski@gnu.org> said that...

Show 7 quoted lines
> Labels on merge conflict lines have changed.  There is no "git rename",
> use cg-mv instead.  In one case stack.h is not created, so copy
> stack.h~master to stack.h before fixing it.
> 
> Also fix comments in script.sh to use the new labels.
> 
> Signed-off-by: Pavel Roskin <proski@gnu.org>
Whoops, overlooked this and already fixed it on my own. Thanks anyway.
Show 7 quoted lines
> @@ -308,6 +308,7 @@ echo "Merge with 0.4" | cg-merge && shou
>  # Mishandled stack.h
>  ed Makefile < $TOP/0021-bob-alice-fixup1.ed
>  ed rpn.c    < $TOP/0022-bob-alice-fixup2.ed
> +cp stack.h~master stack.h
>  ed stack.h  < $TOP/0023-bob-alice-fixup3.ed
>  cg-add stack.h
Isn't it enough to just kill ~master and move ~origin there, though?
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time.  I think
I have forgotten this before.
Pavel Roskin· Mar 3, 2006, 01:11 UTC · re: Pavel Roskin · lore

[PATCH 3/3] Allow the tutorial script to be run by "make test"

Signed-off-by: Pavel Roskin <proski@gnu.org>
---
 Documentation/Makefile                 |    4 ++++
 Documentation/tutorial-script/Makefile |    5 +++++
 Makefile                               |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)
Show changes to 3 files +10 −0

Documentation/Makefile, Documentation/tutorial-script/Makefile, Makefile

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 3aad2fb..e5508e8 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -55,7 +55,11 @@ install-html: html
 	$(INSTALL) -m755 -d $(DESTDIR)/$(htmldir)
 	$(INSTALL) $(DOC_HTML) $(DESTDIR)/$(htmldir)
 
+test:
+	make -C tutorial-script test
+
 clean:
+	make -C tutorial-script clean
 	rm -f *.xml *.html *.1 *.7 cg*.txt $(PACKAGE).txt
 
 .PRECIOUS: cg%.txt
diff --git a/Documentation/tutorial-script/Makefile b/Documentation/tutorial-script/Makefile
new file mode 100644
index 0000000..bdf384f
--- /dev/null
+++ b/Documentation/tutorial-script/Makefile
@@ -0,0 +1,5 @@
+test:
+	./script.sh
+
+clean:
+	rm -rf Playground
diff --git a/Makefile b/Makefile
index 994b182..2b53641 100644
--- a/Makefile
+++ b/Makefile
@@ -59,6 +59,7 @@ doc:
 
 test: all
 	$(MAKE) -C t/ all
+	$(MAKE) -C Documentation/ test
 
 
 
Junio C Hamano· Mar 3, 2006, 05:27 UTC · re: Pavel Roskin · lore

Re: [PATCH 1/3] cg-mv doesn't work with bash 3.1.7 due to excessive quotes

Pavel Roskin <proski@gnu.org> writes:
> -	ARGS2["${#ARGS2[@]}"]="$_git_relpath${arg%/}"
> +	ARGS2[${#ARGS2[@]}]="$_git_relpath${arg%/}"

Is this an application bug? It looks like a workaround for a bug in the shell...

Not that I care too much either way -- I do not use shell arrays myself ;-).

Pavel Roskin· Mar 3, 2006, 14:11 UTC · re: Junio C Hamano · lore

Re: [PATCH 1/3] cg-mv doesn't work with bash 3.1.7 due to excessive quotes

On Thu, 2006-03-02 at 21:27 -0800, Junio C Hamano wrote:
Show 7 quoted lines
> Pavel Roskin <proski@gnu.org> writes:
> 
> > -	ARGS2["${#ARGS2[@]}"]="$_git_relpath${arg%/}"
> > +	ARGS2[${#ARGS2[@]}]="$_git_relpath${arg%/}"
> 
> Is this an application bug?  It looks like a workaround for a
> bug in the shell...

Indeed, bash 3.00.16 (FC4) is fine with the original cg-mv. On the other hand, bash 3.1.7 (FC development) doesn't even like this:

$ arg["0"]=0 bash: "0": syntax error: operand expected (error token is ""0"")

I don't see any relevant information in the NEWS file, so even if it's no a bug, it's an undocumented feature :-)

Anyway, the quotes are excessive, bash is (sort of) correct to complain about it, and I don't see any other instances of quoting array arguments in cogito.

The quotes in question have always existed in cg-mv, they were not added to work around anything.

-- 
Regards,
Pavel Roskin
Pavel Roskin· Mar 10, 2006, 20:48 UTC · re: Pavel Roskin · lore

Re: [PATCH 1/3] cg-mv doesn't work with bash 3.1.7 due to excessive quotes

Hello, Petr!
On Fri, 2006-03-03 at 09:11 -0500, Pavel Roskin wrote:
Show 5 quoted lines
> On Thu, 2006-03-02 at 21:27 -0800, Junio C Hamano wrote:
> > Pavel Roskin <proski@gnu.org> writes:
> > 
> > > -	ARGS2["${#ARGS2[@]}"]="$_git_relpath${arg%/}"
> > > +	ARGS2[${#ARGS2[@]}]="$_git_relpath${arg%/}"

Any issues with this patch? FC5 is due in a week. Expect and outcry from the new bash 3.1.7 users if the fixed cogito is not available shortly.

Bash is not as wrong as it may seem. Left hand side in assignments is already a special case in earlier versions of bash, just not in the index:

bash 3.00.16 (FC4) $ f"oo"=bar bash: foo=bar: command not found $ foo["0"]=bar $

bash 3.1.7 (FC5) $ f"oo"=bar bash: foo=bar: command not found $ foo["0"]=bar bash: "0": syntax error: operand expected (error token is ""0"") $

-- 
Regards,
Pavel Roskin
Josef Weidendorfer· Mar 3, 2006, 16:34 UTC · re: Junio C Hamano · lore

Re: [PATCH 1/3] cg-mv doesn't work with bash 3.1.7 due to excessive quotes

On Friday 03 March 2006 06:27, you wrote:
Show 7 quoted lines
> Pavel Roskin <proski@gnu.org> writes:
> 
> > -	ARGS2["${#ARGS2[@]}"]="$_git_relpath${arg%/}"
> > +	ARGS2[${#ARGS2[@]}]="$_git_relpath${arg%/}"
> 
> Is this an application bug?  It looks like a workaround for a
> bug in the shell...
This line in cg-mv is needed to work around at least two
bugs in git-mv:
* "git-mv a/ b/" not working.
  Fix was to strip all trailing slashes of args (fixed in 1.2.4)
* "cd subdir; git-mv ../file ."
  Fix is to run git-mv from base directory (see separate patch for git-mv)
I think cg-mv should be able to be a direct wrapper for git-mv with
the next maintenance release.
Pasky: do you know of other problems with git-mv?
Josef

← back to recent threads