Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The installer exits without waiting for the completion of git clone #11

Open
crhg opened this issue Nov 12, 2018 · 2 comments
Open

The installer exits without waiting for the completion of git clone #11

crhg opened this issue Nov 12, 2018 · 2 comments

Comments

@crhg
Copy link

crhg commented Nov 12, 2018

The installer exits without waiting for the completion of git clone. This is not a problem when running the installer manually. However, if you write .zshrc to automatically run the installer if zplug is not installed, subsequent processing using zplug will cause an error depending on the timing.

It seems that spin() is responsible for waiting for the job to finish, but it does not seem to work well.

If you add the following code to the end of the installer, the output will be as follows. It is expected to wait for 10 seconds sleeping, but in fact it finished almost immediately.

date
execute \
    --title \
    "sleep 10" \
    "sleep 10"
date
% cat installer.zsh | zsh
 ✔  Checking if your zsh version is newer than 4.1.9 [SUCCEEDED]
 ✔  Installing zplug to /Users/matsui/.zplug [SUCCEEDED]
 All processes are successfully completed 🎉
 For more information, see http://zplug.sh 🌺
 Enjoy zplug!
Mon Nov 12 17:16:24 JST 2018
 ✔  sleep 10 [SUCCEEDED]
Mon Nov 12 17:16:25 JST 2018

My environment is as follows.

zsh 5.6.2 (x86_64-apple-darwin18.0.0)
GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)

@crhg
Copy link
Author

crhg commented Nov 13, 2018

I tried it on another machine in the same way and it worked as expected here.

% cat installer.zsh| zsh
 ✔  Checking if your zsh version is newer than 4.1.9 [SUCCEEDED]
 ✔  Installing zplug to /home/matsui/.zplug [SUCCEEDED]
 All processes are successfully completed 🎉
 For more information, see http://zplug.sh 🌺
 Enjoy zplug!
2018年 11月 13日 火曜日 09:29:20 JST
 ✔  sleep 10 [SUCCEEDED]
2018年 11月 13日 火曜日 09:29:30 JST

The environment is as follows.

zsh 5.4.2 (x86_64-ubuntu-linux-gnu)
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2)

@crhg
Copy link
Author

crhg commented Nov 15, 2018

In zsh-5.6.2 I found that connecting echo $jobstates to pipe will make the output empty even if there are some jobs. This does not occur for zsh 5.4.2.

% sleep 30
^Z
zsh: suspended  sleep 30
% echo $jobstates
suspended:+:16815=suspended
% echo $jobstates | cat

% echo $jobstates
suspended:+:16815=suspended

I asked about this on the zsh-users mailing list and got the answer that this is the effect of bug fixes made in 5.6. In order to prevent the left side of the pipe operator executed by subshell from influencing the parent, parameter expansion is performed after forking, and it seems that $jobstates becomes empty because subshell does not have a job. For details, see the thread from zsh-users 23756.

As a result, it seems that the logic for judging completion of job in the spin() function is not working properly.

        echo "$jobstates" \
            | awk '
            /[0-9]+=/ {
                jobs[++job_count] = $0
            }
            END {
                for (i = 1; i <= job_count; i++) {
                    print(jobs[i])
                }
                exit job_count == 0
            }' \
                | xargs test -z && break

I think that the part here can be written as follows without using pipes.

        [ $#jobstates = 0 ] && break

crhg added a commit to crhg/zplug_installer that referenced this issue Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant