Skip to main content
11 events
when toggle format what by license comment
Feb 17, 2023 at 13:38 comment added Dennis Williamson @Tiina: The first part of that quote is "if you define them in ~/.bashrc". Of course, you also need to shopt -s expand_aliases in the script.
Feb 17, 2023 at 6:33 comment added Tiina quote: unless you source ~/.bashrc in the script, not really, "source ~/.bashrc" does not allow alias to be used in scripts either.
Jun 28, 2022 at 23:46 comment added Dennis Williamson @Akito: I'm not sure what you mean. It works for me.
Jan 29, 2020 at 18:10 comment added Akito This does not solve the problem when the contents of the function needs to be evaluated in the script that got the function from another script...
Aug 13, 2019 at 16:10 comment added Dennis Williamson @Fmstrat: b () { bash "$@"; } then b -c "echo test | grep test"
Aug 13, 2019 at 16:03 comment added Fmstrat The problem here is when you need an alias that you pass lots of quoted options to. for instance as an example, alias b=bash makes it easy to do b -c "echo test | grep test" which would be difficult to do in functions.
May 21, 2018 at 18:35 comment added Phylliida While this doesn't technically answer the question, as you say you can simply replace alias commandA=... with commandA() { ... } then export commandA and you get identical behavior to the alias. So this is pretty much an identical alternative to aliases as far as I know that works great in bash scripts
May 9, 2013 at 14:03 history edited Dennis Williamson CC BY-SA 3.0
improve grammar
S Aug 21, 2011 at 3:08 history suggested Tyilo CC BY-SA 3.0
Added example of exporting a function
Aug 21, 2011 at 2:47 review Suggested edits
S Aug 21, 2011 at 3:08
Sep 2, 2010 at 20:38 history answered Dennis Williamson CC BY-SA 2.5