protected function findShellConfigFile()
    {
        // Special handling for the .environment file on Platform.sh environments.
        $envPrefix = $this->config()->get('service.env_prefix');
        if (getenv($envPrefix . 'PROJECT') !== false
            && getenv($envPrefix . 'APP_DIR') !== false
            && getenv($envPrefix . 'APP_DIR') === Filesystem::getHomeDirectory()) {
            return getenv($envPrefix . 'APP_DIR') . '/.environment';
        }

        $shell = null;
        if (getenv('SHELL') !== false) {
            $shell = basename(getenv('SHELL'));
            $this->debug('Detected shell: ' . $shell);
        }

        $candidates = [
            '.bashrc',
            '.bash_profile',
        ];

        // OS X ignores .bashrc if .bash_profile is present.
        if (OsUtil::isOsX()) {
            $candidates = [
                '.bash_profile',
                '.bashrc',
            ];
        }

        if ($shell === 'zsh' || getenv('ZSH')) {
            array_unshift($candidates, '.zshrc');
            array_unshift($candidates, '.zprofile');
        }

        $homeDir = Filesystem::getHomeDirectory();
        foreach ($candidates as $candidate) {
            if (file_exists($homeDir . DIRECTORY_SEPARATOR . $candidate)) {
                $this->debug('Found existing config file: ' . $homeDir . DIRECTORY_SEPARATOR . $candidate);

                return $homeDir . DIRECTORY_SEPARATOR . $candidate;
            }
        }

        // If none of the files exist (yet), and we are on Bash, and the home
        // directory is writable, then use ~/.bashrc.
        if (is_writable($homeDir) && $shell === 'bash') {
            $this->debug('Defaulting to ~/.bashrc');

            return $homeDir . DIRECTORY_SEPARATOR . '.bashrc';
        }

        return false;
    }
protected function findShellConfigFile()
    {
        // Special handling for the .environment file on Platform.sh environments.
        $envPrefix = $this->config()->get('service.env_prefix');
        if (getenv($envPrefix . 'PROJECT') !== false
            && getenv($envPrefix . 'APP_DIR') !== false
            && getenv($envPrefix . 'APP_DIR') === Filesystem::getHomeDirectory()) {
            return getenv($envPrefix . 'APP_DIR') . '/.environment';
        }

        $shell = null;
        if (getenv('SHELL') !== false) {
            $shell = basename(getenv('SHELL'));
            $this->debug('Detected shell: ' . $shell);
        }

        $candidates = [
            '.bashrc',
            '.bash_profile',
        ];

        // OS X ignores .bashrc if .bash_profile is present.
        if (OsUtil::isOsX()) {
            $candidates = [
                '.bash_profile',
                '.bashrc',
            ];
        }

        if ($shell === 'zsh' || getenv('ZSH')) {
            array_unshift($candidates, '.zshrc');
            array_unshift($candidates, '.zprofile');
        }

        $homeDir = Filesystem::getHomeDirectory();
        foreach ($candidates as $candidate) {
            if (file_exists($homeDir . DIRECTORY_SEPARATOR . $candidate)) {
                $this->debug('Found existing config file: ' . $homeDir . DIRECTORY_SEPARATOR . $candidate);

                return $homeDir . DIRECTORY_SEPARATOR . $candidate;
            }
        }

        // If none of the files exist (yet), and we are on Bash, and the home
        // directory is writable, then use ~/.bashrc.
        if (is_writable($homeDir) && $shell === 'bash') {
            $this->debug('Defaulting to ~/.bashrc');

            return $homeDir . DIRECTORY_SEPARATOR . '.bashrc';
        }

        return false;
    }
protected function findShellConfigFile ( ) { // Special handling for the .environment file on Platform.sh environments. $ envPrefix = $ this -> config ( ) -> get ( 'service.env_prefix' ) ; if ( getenv ( $ envPrefix . 'PROJECT' ) !== false && getenv ( $ envPrefix . 'APP_DIR' ) !== false && getenv ( $ envPrefix . 'APP_DIR' ) === Filesystem :: getHomeDirectory ( ) ) { return getenv ( $ envPrefix . 'APP_DIR' ) . '/.environment' ; } $ shell = null ; if ( getenv ( 'SHELL' ) !== false ) { $ shell = basename ( getenv ( 'SHELL' ) ) ; $ this -> debug ( 'Detected shell: ' . $ shell ) ; } $ candidates = [ '.bashrc' , '.bash_profile' , ] ; // OS X ignores .bashrc if .bash_profile is present. if ( OsUtil :: isOsX ( ) ) { $ candidates = [ '.bash_profile' , '.bashrc' , ] ; } if ( $ shell === 'zsh' || getenv ( 'ZSH' ) ) { array_unshift ( $ candidates , '.zshrc' ) ; array_unshift ( $ candidates , '.zprofile' ) ; } $ homeDir = Filesystem :: getHomeDirectory ( ) ; foreach ( $ candidates as $ candidate ) { if ( file_exists ( $ homeDir . DIRECTORY_SEPARATOR . $ candidate ) ) { $ this -> debug ( 'Found existing config file: ' . $ homeDir . DIRECTORY_SEPARATOR . $ candidate ) ; return $ homeDir . DIRECTORY_SEPARATOR . $ candidate ; } } // If none of the files exist (yet), and we are on Bash, and the home // directory is writable, then use ~/.bashrc. if ( is_writable ( $ homeDir ) && $ shell === 'bash' ) { $ this -> debug ( 'Defaulting to ~/.bashrc' ) ; return $ homeDir . DIRECTORY_SEPARATOR . '.bashrc' ; } return false ; }
Finds a shell configuration file for the user.

@return string|false
The absolute path to a shell config file, or false on failure.
Finds a shell configuration file for the user .