I'm having trouble with the behavior difference in zsh when using the jobs command. Specifically,
#!/bin/zsh
for in {1..10}; do
sleep1&
jobs | wc-l
jobs
done
If you execute this, the number of lines counted by wc will remain at 0.
while the command (sleep) being executed increases.
Try #!/bin/bash instead of #!/bin/zsh and it will work as expected (wc-l output is increasing).
Also, even in the case of zsh, if the above program is entered directly on the terminal, we have confirmed that it works as expected like bash.
Run in
·OS: Debian (stretch 9.3)
·zsh: 5.3.1
·bash: 4.4.12
That's right.
I'm sorry to trouble you, but I'd appreciate it if you could let me know if anyone knows the cause.
I look forward to your kind cooperation.
Although you have not read the details carefully, running setopt monitor
results in the desired behavior.Note: https://unix.stackexchange.com/a/227411/157713
#!/bin/zsh
setopt monitor
for in {1..10}; do
sleep1&
jobs | wc-l
jobs
done
# =>wc results show the number of jobs
606 Uncaught (inpromise) Error on Electron: An object could not be cloned
567 Who developed the "avformat-59.dll" that comes with FFmpeg?
597 GDB gets version error when attempting to debug with the Presense SDK (IDE)
884 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.