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

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:20

Pavel Roskin [off-list ref] 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 ;-).

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

From: Pavel Roskin <hidden>
Date: 2016-06-15 22:42:21

On Thu, 2006-03-02 at 21:27 -0800, Junio C Hamano wrote:
Pavel Roskin [off-list ref] writes:
quoted
-	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

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

From: Josef Weidendorfer <hidden>
Date: 2016-06-15 22:42:21

On Friday 03 March 2006 06:27, you wrote:
Pavel Roskin [off-list ref] writes:
quoted
-	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

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

From: Pavel Roskin <hidden>
Date: 2016-06-15 22:42:21

Hello, Petr!

On Fri, 2006-03-03 at 09:11 -0500, Pavel Roskin wrote:
On Thu, 2006-03-02 at 21:27 -0800, Junio C Hamano wrote:
quoted
Pavel Roskin [off-list ref] writes:
quoted
-	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help