0

Neither functions seem to affect anything for me? Is anyone able to get them working and show me what I'm doing wrong?

I'm trying to override git pull to include recursive submodules whilst keeping other git commands work

#https://superuser.com/a/479816
function git() {
  case $* in
    -pull* ) shift 1; command git pull --recurse-submodules "$@" ;;
    * ) command git "$@" ;;
  esac
}

function ls() { case $* in -la* ) shift 1; command ls -la "$@" | more ;; * ) command ls "$@" ;; esac }

Destroy666
  • 12,350
P1000
  • 1

1 Answers1

0

Your script doesn't make much sense in the 1st place as it's trying to match git -pull, git -pulled123 and similar statements. I would recommend to read about functionalities you're trying to use, such as case matching with wildcard (*) or what $* means (argument string).

Regardless, not going into that too deep because it's not the way to go. The most proper way to define git aliases is and will be to use git config --global alias.xyz "definition", e.g. here:

git config --global alias.rpull "pull --recurse-submodules"

You can't overwrite the command this way, but you can use a very similar one. And overriding is generally a bad idea as you might want to use regular pull one day and you'll have to get rid of the script at least temporarily. There are definitely cases when you don't want to pull submodules recursively. It's also suboptimal for repos without submodules.

Destroy666
  • 12,350