0

I have the following setup:

#!/bin/bash

function outer() {
  function inner() {
    ...
  }

  ... | xargs -L1 inner

}

So, I want to call inner for each of the lines that are generated in outer and call the function from an interactive shell. How would I do that?

I've tried exporting the inner function (from within outer) but that has no effect as I get 'no such file or directory'.

Note that inner calls xargs too, so for each output piped from outer to inner there will multiple executions (in case that makes a difference).

Max Power
  • 952
  • 9
  • 24
  • It's _not_ a duplicate because the accepted answer for the suggested duplicate question does not work, as explained. – Max Power Jul 27 '18 at 07:47
  • Instead of using xargs, pipe to a while loop. It can do while read line to read one line at a time and then run inner "$line". Zsh might work better if you want side effects on the shell because it runs the left of pipelines in a subshell rather than the right. – okapi Jul 27 '18 at 19:02

0 Answers0