What you're asking doesn't really make much sense.
keyword means it's a word that is part of the syntax of the shell. Those are recognised through tokenising. Quoting them is enough for the shell to stop recognising.
It is possible to alias a keyword in most shells though. So, aliases have precedence over keywords (in effect they are expanded early, and there is more tokenising after that where you can have more aliases, keywords)...
aliases (with the exception of zsh aliases defined with alias -g
are only expanded in command position), so typically not in builtin the-alias
.
functions have precedence over builtins, and builtins over external commands (and then $PATH
decides which one to use).
You can force the builtin with:
builtin the-cmd and its args
(though it should be noted it is not a standard command).
You can disable aliases by quoting them (though the quoted version could also be aliased in some shells).
So, for instance (here zsh syntax), in:
'while'() echo function while
alias 'while=echo alias while'
Writing while true
would actually output alias while true
, and there would be no way to use the while
keyword since quoting it would disable both the alias and keyword.
You would call the while
function with for instance:
'whi'le whatever
If there was a while
builtin (but of course their wouldn't in those shells that have while
keyword), you'd write it:
builtin while whatever
And to call the while
command, you'd write:
env while whatever
or in zsh
(when not in sh
emulation):
command while whatever
(in other shells, command
only prevents functions, not builtins)
Or
/full/path/to/while whatever
Of course, nothing's stopping you from doing even sillier things like:
alias 'while=while "w"hile; do'
"while"() { while "whi"le; done; }
Which, at least in zsh is valid (but stupid).
An alias is expanded simply by replacing the alias by its definition (as a list of tokens, not a string, which is basically equivalent to taking the string and adding a space at the end). So stopdev; true
is expanded to
cd $HOME/website; make website_stop; make backend_stop; ; true
^^^
Since you can't have two consecutive semicolons in the shell syntax, that's a syntax error.
You can remove the ;
, and that will make stopdev; startev
work, but it isn't good, because any argument you pass to stopdev
will be passed to make backend_stop
, which is probably not desirable.
You should make this a function. Also, don't run the make
commands if the cd
command fails.
stopdev () {
cd "$HOME/website" && {
make website_stop
make backend_stop
}
}
An improvement would be to make the function return a failure code even if make website_stop
fails but make backend_stop
succeeds.
stopdev () {
cd "$HOME/website" && {
make website_stop
ret=$?
make backend_stop && return $ret
}
}
Note that this leaves you in the ~/website
directory. To avoid changing the directory of the shell process, run the function in a subshell.
stopdev () (
cd "$HOME/website" && {
make website_stop
ret=$?
make backend_stop && return $ret
}
)
Alternatively, with GNU make, you can use its -C
option.
stopdev () {
make -C "$HOME/website" website_stop
ret=$?
make -C "$HOME/website" backend_stop && return $ret
}
If the targets never fail, just pass them both.
stopdev () (
cd "$HOME/website" && make website_stop backend_stop
)
or
stopdev () {
make -C "$HOME/website" website_stop backend_stop
}
Best Answer
Be careful when using the
which
command. Better to use thetype ...
command.You can also use the
whereis
command: