by TacticalCoder · 4y ago · 0 comments
The alias itself looks a bit weird in that to pass arguments to an aliased command you need to use a function (in Bash at least AFACIT) but it all works fine.
As aliases aren't sourced when other scripts are running, I'm sure my scripts/commands ain't ever going to clash with anything.
I've been doing that since years.
It also works fine to add "wrappers" to existing commands: for example to add additional input sanitization catching common mistakes I'm making when calling some commands.
No you don't:
$ alias say=echo
$ say beep
beep
You do need to do something special the other way around (if you wrap a command in a function it needs to explicitly pass the arguments on). function ,foo() { printf "Fooo\n"; }
,foo
actually works! (at least in my bash 5.0.17 shell) alias watch='watch '
Specifically, if an alias ends with a space, it will cause the subsequent arg to be expanded as well. For example, try running: alias beep=echo
watch beep hello # This will fail
alias watch='watch '
watch beep hello # Now it works!
[1]: https://news.ycombinator.com/item?id=31830879.foo1,.foo2, .foo3, and so on.