Search code examples
macosbashunix.profile

How to get original system command after overwriting it with a function?


I'm at a Hackathon right now so if someone would answer this soon, you'd be doing me a huge favor.

I've written a function called ls() in my .profile that looks like this:

ls() {

  if(some condition);
    do something
  else
    ls; #(CALL TO ORIGINAL ls SYSTEM CALL)
  fi

}

But here when it goes to the else part, it just enters an infinite loop

How can I call the original ls system call in else Or, how can I make ls behave differently in one folder and normally in the others.


Solution

  • Use the full path to the executable:

    /bin/ls