Skip to main content
8 events
when toggle format what by license comment
Mar 24, 2021 at 15:08 comment added Peter Cordes And this is why I usually use && when chaining long-running commands (like cp or rsync) instead of ;, in case I want to change my mind about what I'm queueing up after this one finishes.
Mar 23, 2021 at 8:10 history edited Stéphane Chazelas CC BY-SA 4.0
added 184 characters in body
Mar 23, 2021 at 8:08 comment added Stéphane Chazelas @OlivierDulac,but if it had to be done like you say, how would the shell handle it? Note that zsh's behaviour is already an improvement on most other shells where when you press Ctrl-Z while a function or compound command is running for instance, it interrupts the whole command and you can resume it later, though that's then done in a subshell, so in a subshell environment which means changes are lost once the interrupted and resumed function returns. Here if you want to be able to stop/resume a chain, you should start it in a subshell.
Mar 23, 2021 at 7:52 comment added Olivier Dulac wow, that's highly unexpected... && or || is usually there to ensure the right hand part is done only if the left hand part was complete (and resp exited with 0 or >0). suspending shouldn't change that, it makes little sense (and is counter intuitive). Thanks for the heads up (I usually am happy to use ctrl-z to pause something when needed, but now I will be very worried if the command is complex)
Mar 23, 2021 at 6:35 comment added Stéphane Chazelas @OlivierDulac, no it will not, not in zsh, that && sudo poweroff will be evaluated at the time ./command is suspended and the job returns the first time with an exit status of 148. It's only if you entered fg && sudo poweroff instead of fg alone that sudo poweroff would be run once ./command exits successfully (without being suspended again).
Mar 23, 2021 at 4:47 comment added Olivier Dulac Once the ./command resumes (I assume op wants to finish that task) it will be still attached to the && sudo poweroff, so the problem remains? is there a way to cancel that && command? maybe rename the poweroff command temporarily?
Mar 22, 2021 at 11:10 vote accept Max Matti
Mar 22, 2021 at 10:46 history answered Stéphane Chazelas CC BY-SA 4.0