Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 1
    Annoyingly I read the man pages, but only looked at the flags to see if an option existed and after some googling, I was convinced that it quits after the first error. Thank you! Commented Feb 10, 2020 at 21:37
  • 1
    TBH when I saw your question it surprised me that xargs quit at all. I've learned something new today too, thank you. Commented Feb 10, 2020 at 21:50
  • 3
    @HoshSadiq instead of that shell loop, you can do everything much simpler with .. | xargs -0 sh -c 'exec_script "$@" || exit 255' sh (adjust for the other options you're passing to xargs and your script). Commented Feb 10, 2020 at 23:08
  • Also, do the files really need to be sorted first? If not, you can get rid of xargs and use find ... \( -exec script {} \; -o -quit \) instead. Commented Feb 10, 2020 at 23:11
  • @mosvy actually I much prefer the loop, originally I didn't use it because the script was meant to run on a posix shell, meaning -d wasn't available for read, later I refactored it so it runs through the host's bash and only executes the scripts in the chroot, but I guess I didn't think to go back to looping. In addition, using the loop doesn't require exporting the variables and/or functions. And yes, it's a simple way of creating script execution order as there's some dependencies and for some reason find does not sort them correctly though I've prefixed them with numbers. Commented Feb 11, 2020 at 8:08