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

RANDOM shell expansion



Hi there

I'm new here and I'm not a subscriber, just wanted to report something funny I stumbled upon on zsh -f (v5.9).

$ for i in {1..9}; do timeout 1 sleep 2 >"/tmp/testrandzshf-${i}-${RANDOM}"; done
$ ls /tmp/testrandzshf-*/tmp/testrandzshf-1-10912 /tmp/testrandzshf-2-10912 /tmp/testrandzshf-3-10912 /tmp/testrandzshf-4-10912 /tmp/testrandzshf-5-10912 /tmp/testrandzshf-6-10912 /tmp/testrandzshf-7-10912 /tmp/testrandzshf-8-10912 /tmp/testrandzshf-9-10912

Not very random :)

Notice that:
1. The expansion is happening on each iteration ($i is correct);
2. Trying with "echo" works - which makes me think it only fails for commands that exit code > 0;
3. However, it also works with "false".

It seems to me even if *just the first iteration* exits with exitcode > 0, the problem happens.

I tried this on bash and it works as expected.

-- Luis Estrozi


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