Pergunta

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.

Foi útil?

Solução

Use the full path to the executable:

/bin/ls

Outras dicas

The command built-in performs command lookup without considering functions:

ls() {

  if(some condition);
    do something
  else
    command ls
  fi

}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top