1

The bash manual says for alias,

There is no mechanism for using arguments in the replacement text, as in csh. If arguments are needed, a shell function should be used (see Section 3.3 [Shell Functions], page 17).

What do the two sentences mean?

"using arguments in the replacement text" doesn't seem to mean the following, which succeeds

$ alias foo="echo bac" 
$ foo
bac
$ foo hello
bac hello
Tim
  • 101,790
  • That's not using an argument. The macro was simply replaced with the expansion, and the argument is still there after it. But there's no way to substitute an argument into the middle of the command. – Barmar Dec 19 '16 at 05:35

1 Answers1

1

I suppose the wording is not perfect, unless you take it very literally. Bash does not replace any aliased text with arguments; it will append arguments to the text, as you saw. This is in contrast with CSH aliases which expands arguments inside the replacement text.

The second sentence, IMHO, stems from the above restriction, and encourages the more-flexible function definitions over the simplistic aliases.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255