Skip to main content
2 of 2
replaced http://meta.stackexchange.com/ with https://meta.stackexchange.com/

Most shells restrict the name of functions to contain only characters that don't need to be quoted, which excludes >.

Even in the few shells that allow > as a function name (I only know of zsh), defining a function called > would only have an effect if you called > as a command (which would require quoting it, i.e. running \> or ">" or '>'). It would not change how redirection works.

None of the usual shells have a way to configure what happens if some subsequent part of the script performs a redirection. If you need that kind of things, a shell is not nearly a flexible enough language. But there's probably a better way to solve whatever problem you're trying to solve — and quite possibly one that can be solved in a shell script.

Gilles 'SO- stop being evil'
  • 866.1k
  • 205
  • 1.8k
  • 2.3k