0

I have aliases for many commands with their verbose flags, e.g.:

alias ninja='ninja --verbose -j 0'

Is there a mechanism in bash, where I can deactivate this flag afterwards?

I tried stuff like:

ninja --verbose=0

but that didn't work out.

I know that I can hide my output with /dev/null or that I can execute the binary directly with /path/to/ninja, but that's not the intent of my question. The answer might be command specific and depends on which mechanism for passing parameters the appropriate program uses, e.g. getopts. Anyways, I am looking forward to your help.

EDIT: From comments I learned, that command ninja or escaping like nin\ja will ignore the complete alias, but not a specific parameter.

h0ch5tr4355
  • 2,092
  • 4
  • 28
  • 51
  • 4
    I suggest `\ninja` or `command ninja` to disable alias for only this moment. – Cyrus Aug 23 '19 at 06:58
  • So these commands are equivalent and ignore aliases? @Cyrus – h0ch5tr4355 Aug 23 '19 at 07:25
  • Aliases are ignored if any of the characters are quoted (for example using a backslash). [See also](https://stackoverflow.com/a/16506263/1016216) – L3viathan Aug 23 '19 at 07:27
  • Note that this only ignores aliases, not shell functions. Use `command ninja` to bypass both. – L3viathan Aug 23 '19 at 07:27
  • 2
    @L3viathan: I suggest to close this question with your linked question/answer. – Cyrus Aug 23 '19 at 07:29
  • This would answer my question for the ninja case, however with more complex aliases it doesn't work as all options are turned off and not only a specific one. In my example this use-case was not completely described. – h0ch5tr4355 Aug 23 '19 at 07:29
  • Possible duplicate of [Why start a shell command with a backslash?](https://stackoverflow.com/questions/15691977/why-start-a-shell-command-with-a-backslash) – L3viathan Aug 23 '19 at 08:19
  • @h0ch5tr4355 Some applications support overriding options by supplying the option again, but that depends on the tool. – L3viathan Aug 23 '19 at 08:19
  • This might help: `\ninja -j 0` – Cyrus Aug 23 '19 at 08:23
  • 1
    I don't know if this would help you out here, but one can also define aliases with arguments `alias echo='command echo "$*"'` – pyr0 Aug 23 '19 at 14:32

0 Answers0