MacOS – Damaged preference file in /bin/sh

bashcommand linemacbook promacosterminal

Today in Drive Genius 3, I ran the “Verify Preferences” function in Repair. It yielded this strange result:

/bin/sh: xargs: command not found

The only option Drive Genius gives is to remove the file, and it seems like I probably shouldn't remove a file in /bin!
Can somebody help me fix this problem and tell me what I should do? My specs are below. Thanks!

MacBook Pro (13-inch, Early 2011)
OS X Yosemite (10.10)
Error was found using Drive Genius 3.2.4 running on a bootable USB drive

Best Answer

This is somewhat speculative, but too long to fit in a comment.

The error message sounds like Drive Genius calls a helper script which attempts to run sh and which contains an error which botches the PATH inside this script.

The proof of concept is something like

#!/bin/sh
PATH=  # oops
xargs </dev/null

Without access to Drive Genius, it's near impossible to find the precise location of the error. The command could be hard-coded into a binary which does something like

execvp("sh", "-c", "PATH=; xargs");

which will be hard to find, and impossible to fix, without access to the program's source code.

A common beginner error is choosing PATH as your variable name for something which doesn't want to actually modify the shell's executable search path. The guidance for shell scripts is to only use lowercase variable names for your script's internal variables, but this advice is widely ignored, even in scripts written by so-called professionals.