"I think I'm going crazy here!"
I recognized the voice at the other end of the phone line. "What's up?", I asked.
"I need to front-end ls, so I put my version in /specialstuff, but the stupid machine keeps using the ls in /bin. It's driving me nuts!"
Front-ending or front-loading is simply putting a special version of a command earlier in $PATH than a system command of the same name. Often the script or program calls the real system command with certain options or flags set to make it easier for users. Because the new version is earler in $PATH, it gets used rather than the system command.
"So you added /specialstuff at the front of $PATH ?". A rhetorical question, but I had to ask it.
"Duh, yes. What's really driving me crazy is that 'which ls' SAYS that ls is in /specialstuff, but when I type it, it doesn't use it. This machine hates me!"
I laughed. "Let me guess," I asked, "you changed $PATH and then put your ls into /specialstuff, right?"
"I don't know. Maybe. Why?"
"Because it matters. I also know that you typed ls after you changed $PATH but before you put your version in /specialstuff."
"Huh? How could you know that?
"Just trust me for a second. Type "hash -r" and then try your ls. Is it OK now?"
I heard keys clicking. "Son of a gun. Now it works. Why?"
Do you know why?
If you found something useful today, please consider a small donation.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2009-11-07 Tony Lawrence