Search code examples
zshzshrc

Can't write function to replicate the functionality of Bash's 'help' command


I'm trying to replicate Bash's help command in my .zshrc. I thought this would work:

function help {
  bash -c "help $@"
}

but this only works when I only pass a single argument -- for instance, help exit. It does not work when I pass options to help, such as help -m exit (which works in Bash). However, literally typing bash -c "help -m exit" works as expected. I imagine this has something to do with how quoting works in the shell, but I can't figure this out.


Solution

  • You can use

    function help {
      bash -c "help $*"
    }