[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: My script almost works but spams the terminal its launched from if useing dash.



Hi,

Jeremy Nicoll wrote:
> would anyone ever code:
>  bin/mailwatcher 2>&1 >/dev/null
> when surely all they need is
>  bin/mailwatcher >/dev/null

Interesting question. (Like what is the use case of cat(1) ?)
Surely this is one of the less useful variations of the rules
for redirection.


Let's assume a subordinate script which expects to get started
with stdout redirected to some non-vanilla target.
For some reason it could decide to direct the stderr of one of
its own sub-subordinate scripts to stdout as prepared by its
superior script and to direct the sub-subordinate stdout to /dev/null.

Superior:

  subordinate | result_consumer

Subordinate

  ...
    echo "Note: Switching to diagnostic output mode"
    subsubordinate 2>&1 >/dev/null
  ...

Subsubordinate:

  ... some (in this case) invalid output to stdout ...
  echo "Failed because ..." >&2
  ...


Have a nice day :)

Thomas


Reply to: