Converting an old .cshrc file into a .bash_aliases file. I've run into a few syntax issues regarding the conversion, but this involves a little more in depth knowledge of Bash.
In [t]Csh, the shell would hang when opening xwindow applications, unless they were opened in the background using an ampersand (e.g., firefox &)
. To avoid this, I would create certain aliases in Csh to run the task in the background, but still leave the command line open for options (using \!*
):
alias ff 'firefox \!* &
When this is converted to Bash it'll do something like this:
ff () { command ff "$@" & }
I still am not sure when to use a function and when to use alias, but I came into a predicament when trying to wrap more options around an already defined alias:
win () { command xterm -geometry 105x25 -font 8x13 -bc "$@" & }
blue () { command win -bg gray33 -fg gray39 "$@" ; }
If I remove the command within blue (e.g., blue () { win -bg ...
) it works as expected.
So I'm curious about two things:
- When to use alias vs function definitions?
- When to use command; if I did
alias win='xterm ...'
would I have to docommand win
then?