>> "That doesn't help with sed -i and similar things."
> Can you give an example? I don't know what you mean.
Sure. The first line below is dangerous no matter what zsh does to save you from yourself. The second line is safe no matter which shell you are using, and no matter what other commands are in the pipeline:
sed $SEDOPTIONS "s/$SEARCHTERM/$REPLACEMENT/g" $FILENAME
cat $FILENAME | sed $SEDOPTIONS "s/$SEARCHTERM/$REPLACEMENT/g"
>> "Zsh stops redirection errors"
> Which is what the post I was answering to was complaining about, wasn't it?
That's not how I interpreted "a typo in the rest of the pipeline." Sure, the typo could be a redirection. It could also accidentally set $SEDOPTIONS in the example above to include the '-i' flag.
>> "it won't help even if cat is in the front"
> Why not? "cat > foo" will error out if "foo" exists and NO_CLOBBER is set.
Yes, "cat > foo" will error out, but "cat $FILENAME | sed -i "s/a/b/g" $FILENAME" won't.
> Can you give an example? I don't know what you mean.
Sure. The first line below is dangerous no matter what zsh does to save you from yourself. The second line is safe no matter which shell you are using, and no matter what other commands are in the pipeline:
>> "Zsh stops redirection errors"> Which is what the post I was answering to was complaining about, wasn't it?
That's not how I interpreted "a typo in the rest of the pipeline." Sure, the typo could be a redirection. It could also accidentally set $SEDOPTIONS in the example above to include the '-i' flag.
>> "it won't help even if cat is in the front"
> Why not? "cat > foo" will error out if "foo" exists and NO_CLOBBER is set.
Yes, "cat > foo" will error out, but "cat $FILENAME | sed -i "s/a/b/g" $FILENAME" won't.