private function formatSourceArg($filename)
    {
        $arg = $filename;

        // Replace the home directory with ~, if not on Windows.
        if (DIRECTORY_SEPARATOR !== '\\') {
            $realpath = realpath($filename);
            $homeDir = Filesystem::getHomeDirectory();
            if ($realpath && strpos($realpath, $homeDir) === 0) {
                $arg = '~/' . ltrim(substr($realpath, strlen($homeDir)), '/');
            }
        }

        // Ensure the argument isn't a basename ('source' would look it up in
        // the PATH).
        if ($arg === basename($filename)) {
            $arg = '.' . DIRECTORY_SEPARATOR . $filename;
        }

        // Crude argument escaping (escapeshellarg() would prevent tilde
        // substitution).
        return str_replace(' ', '\\ ', $arg);
    }
private function formatSourceArg($filename)
    {
        $arg = $filename;

        // Replace the home directory with ~, if not on Windows.
        if (DIRECTORY_SEPARATOR !== '\\') {
            $realpath = realpath($filename);
            $homeDir = Filesystem::getHomeDirectory();
            if ($realpath && strpos($realpath, $homeDir) === 0) {
                $arg = '~/' . ltrim(substr($realpath, strlen($homeDir)), '/');
            }
        }

        // Ensure the argument isn't a basename ('source' would look it up in
        // the PATH).
        if ($arg === basename($filename)) {
            $arg = '.' . DIRECTORY_SEPARATOR . $filename;
        }

        // Crude argument escaping (escapeshellarg() would prevent tilde
        // substitution).
        return str_replace(' ', '\\ ', $arg);
    }
private function formatSourceArg ( $ filename ) { $ arg = $ filename ; // Replace the home directory with ~, if not on Windows. if ( DIRECTORY_SEPARATOR !== '\\' ) { $ realpath = realpath ( $ filename ) ; $ homeDir = Filesystem :: getHomeDirectory ( ) ; if ( $ realpath && strpos ( $ realpath , $ homeDir ) === 0 ) { $ arg = '~/' . ltrim ( substr ( $ realpath , strlen ( $ homeDir ) ) , '/' ) ; } } // Ensure the argument isn't a basename ('source' would look it up in // the PATH). if ( $ arg === basename ( $ filename ) ) { $ arg = '.' . DIRECTORY_SEPARATOR . $ filename ; } // Crude argument escaping (escapeshellarg() would prevent tilde // substitution). return str_replace ( ' ' , '\\ ' , $ arg ) ; }
Transform a filename into an argument for the 'source' command.

This is only shown as advice to the user.

@param string $filename

@return string
Transform a filename into an argument for the source command .