Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
unreproducible bug with ${=...}
- X-seq: zsh-workers 45023
- From: frederik@xxxxxxx
- To: Zsh Workers List <zsh-workers@xxxxxxx>
- Subject: unreproducible bug with ${=...}
- Date: Fri, 13 Dec 2019 20:53:30 -0800
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Reply-to: frederik@xxxxxxx
- Sender: <frederik@xxxxxxx>
Dear Zsh Workers,
While working on some backup scripts I ran into what looks like an intermittent bug, which I was not able to reproduce sufficiently consistently to get a minimal test case. I'm not sure if that's helpful to report. Here is the relevant fragment:
...
ssh=ssh
rsync=(rsync)
excludes=(/dvds /tmp .gvfs /fs)
opts=(-a --partial
${=${:-"--exclude "$^excludes}}
-e "$ssh")
cmd=(sudo $rsync $opts $src_paths $dst_path)
>&2 print -l $cmd;
Basically all arguments and variables are the same between one run and the next, but sometimes it prints
...
--exclude /dvds
--exclude /tmp
--exclude .gvfs
...
(prompting a complaint from rsync), whereas usually I get the intended
...
--exclude
/dvds
--exclude
/tmp
--exclude
.gvfs
...
The other parts of the script don't do anything weird, there is a file locking part which creates traps on INT, TERM, and EXIT after some options setting:
unsetopt localtraps # so the 'trap' lasts beyond the function
setopt posix_traps # so that we can trap EXIT
Here is the value of IFS, I don't think I set it anywhere.
$ echo -n \"$IFS\" | od -c
0000000 " \t \n \0 "
0000006
If anyone has some advice about what may be causing this, or how I can debug it or try to get a minimal test case, I'm willing to spend a little more time. I imagine it's somehow my fault, but I can't think of what could be going on here.
I was running the command on an Intel Core 2 Duo laptop, with Arch (zsh 5.7.1).
Thanks,
Frederick
P.S. I switched to using "zip" expansion, as suggested by Mikachu on IRC, which seems more elegant and doesn't use IFS: ${${:---exclude}:^^excludes}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author