tags:

views:

1349

answers:

2

Hello, in tcsh I'm trying to redirect STDERR from a command from my .aliases file.

I found that I can redirect STDERR from the command line like this. . .

$ (xemacs > /dev/tty) >& /dev/null

. . . but when I put this in my .aliases file I get an alias loop. . .

$ cat .aliases
alias xemacs '(xemacs > /dev/tty ) >& /dev/null'
$ xemacs &
Alias loop.
$

. . . so I put a backslash before the command in .aliases, which allows the command to run. . .

$ cat .aliases
alias xemacs '(\xemacs > /dev/tty ) >& /dev/null'
$ xemacs &
[1] 17295
$

. . . but now I can't give the command any arguments:

$ xemacs foo.txt &
Badly placed ()'s.
[1]    Done                          ( \xemacs > /dev/tty ) >& /dev/null
$

Can anyone offer any solutions? Thank you in advance!


UPDATE: I'm still curious if it's possible to redirect STDERR in tcsh from .aliases, but as has been suggested here, I ended up with a shell script:

#!/bin/sh
# wrapper script to suppress messages sent to STDERR on launch
# from the command line.
/usr/bin/xemacs "$@" 2>/dev/null
+1  A: 

I suspect this is a case where NOT using an alias is the best option - try using a shell script instead:

#!/bin/tcsh

(xemacs $* > /dev/tty ) >& /dev/null
Dominic Eidson
A: 

Try

alias emacs '(\emacs \!* > /dev/tty) >& /dev/null'

The "badly placed ()'s" message comes from misplacing the input parameter to emacs. Without the "\!*" in the alias definition, "emacs abc" becomes

(/usr/bin/emacs > /dev/tty) >& /dev/null abc

With the "\!*" included, "emacs abc" becomes

(/usr/bin/emacs abc > /dev/tty) >& /dev/null
J. A. Faucett