On Sun, Nov 03, 2019 at 10:30:53PM -0500, Theodore Y. Ts'o wrote:
> On Sun, Nov 03, 2019 at 11:09:00AM -0800, Darrick J. Wong wrote:
> >
> > Because if you don't do that, the e2scrub process gets started with fd 0
> > mapped to stdout of ls_targets on account of the "ls_targets | while
> > read tgt" loop. Yay bash. I guess the problem here is that
> > e2scrub_all's stdin is itself a pipe, so /dev/stdin maps to
> > /proc/self/fd/0, is a symlink to "pipe:[XXXX]" which doesn't help us
> > any.
> >
> > We could amend the e2scrub_all script to do:
> >
> > stdin="$(realpath /dev/stdin)"
> > test -w "${stdin}" || stdin=/dev/null
>
> Shouldn't that be 'test -r "${stdin}"'?
>
> Or we could just always redirect the input to /dev/null, perhaps?
But even assuming that /dev/null is a suitable stdin is a gross hack.
I'd rather replace the "ls_targets | while" construct with a proper bash
array.
This is easy enough to do with bash 4.xx mapfile command, which we can
use so long as nobody wants us to support e2scrub on RHEL 5. I mean,
Debian "oldoldstable" doesn't even ship 3.xx so that's probably ok,
right? :)
--D
> Cheers,
>
> - Ted