Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Broken specialsed file completion



On Aug 29, 12:56am, Frank Terbeck wrote:
}
} > For some reason the following, which has worked fine for many years, has
} > stopped working.
} >
} > Instead of completing most recently modified files, it reports
} >
} > _path_files:compfiles:466: too few arguments
} 
} I had a bit of time on my hands, so I bisected this down to this commit:
} 
}     39019 (cf. PWS 39013): fix SHWORDSPLIT regression introduced by workers/29313

The difference is this expression (_path_files line 59):

sopt="-${(@j::M)${(@)tmp1#-}#?}"

Previously this would result in sopt='-' but now it appears to yield
sopt='' -- which doesn't seem to make any sense, because the "-" is
outside of the parameter expansion.  However, it's affected by the
setting of rcexpandparam in $_comp_options.

The expansion of ${(@j::M)${(@)tmp1#-}#?} used to result in a scalar
empty string, but now it results in an empty array, and rcexpandparam
discards the "-" because it has no array element with which to pair.

What's happened here is that given (@j::), the @ is forcing an array,
where previously the j would force a string.

I'm still not entirely sure what it should mean to use @ and j in the
same expansion, but clearly it's wrong for the j to be ignored.  Does
the D04 test case below look correct to everyone?


diff --git a/Src/subst.c b/Src/subst.c
index 15eb59b..4641b4b 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3458,7 +3458,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
     if (ssub || spbreak || spsep || sep) {
 	int force_split = !ssub && (spbreak || spsep);
 	if (isarr) {
-	    if (nojoin == 0) {
+	    /* sep non-null here means F or j flag, force join */
+	    if (nojoin == 0 || sep) {
 		val = sepjoin(aval, sep, 1);
 		isarr = 0;
 		ms_flags = 0;
@@ -3467,7 +3468,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 		 * forced joining as previously determined, or
 		 * join on what we later use to forcibly split
 		 */
-		val = sepjoin(aval, (nojoin == 1 ? sep : spsep), 1);
+		val = sepjoin(aval, (nojoin == 1 ? NULL : spsep), 1);
 		isarr = 0;
 	    }
 	}
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 37166fa..0630079 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1986,3 +1986,12 @@
 >one
 >two-bucklemy
 >shoe
+
+  (
+  set -- "one two" "bucklemy shoe"
+  IFS=
+  setopt shwordsplit rcexpandparam
+  print -l "X${(@j.-.)*}"
+  )
+0:Use of @ does not prevent forced join with j
+>Xone two-bucklemy shoe



Messages sorted by: Reverse Date, Date, Thread, Author