Changeset 3435


Ignore:
Timestamp:
Jun 16, 2007, 1:59:14 AM (18 years ago)
Author:
bird
Message:

Some popen hacks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/essentials/dev-lang/python/Modules/posixmodule.c

    r3364 r3435  
    38513851        char *mode = "r";
    38523852        int bufsize = -1;
     3853        int unset_emxshell = 0;
    38533854        FILE *fp;
    38543855        PyObject *f;
    38553856        if (!PyArg_ParseTuple(args, "s|si:popen", &name, &mode, &bufsize))
    38563857                return NULL;
     3858        /* a little hack for making sure commands.getstatusoutput works
     3859         * (ASSUMES that COMSPEC isn't a posix shell.) */
     3860        if (name[0] == '{' && !getenv("EMXSHELL")) {
     3861                char path[512];
     3862                _searchenv("sh.exe", "PATH", path);
     3863                if (!path[0])
     3864                        _searchenv("ash.exe", "PATH", path);
     3865                if (!path[0])
     3866                        _searchenv("bash.exe", "PATH", path);
     3867                if (path[0])
     3868                        unset_emxshell = setenv("EMXSHELL", path, 0) == 0;
     3869        }
    38573870        Py_BEGIN_ALLOW_THREADS
    38583871        fp = popen(name, mode);
    38593872        Py_END_ALLOW_THREADS
     3873        if (unset_emxshell)
     3874                unsetenv("EMXSHELL");
    38603875        if (fp == NULL)
    38613876                return posix_error();
     
    40254040        if ((shell = getenv("EMXSHELL")) == NULL)
    40264041                if ((shell = getenv("COMSPEC")) == NULL)
    4027                 {
    4028                         errno = ENOENT;
    4029                         return posix_error();
    4030                 }
     4042                        if ((shell = getenv("SHELL")) == NULL)
     4043                                if ((shell = getenv("OS2_SHELL")) == NULL)
     4044                                {
     4045                                        errno = ENOENT;
     4046                                        return posix_error();
     4047                                }
    40314048
    40324049        sh_name = _getname(shell);
Note: See TracChangeset for help on using the changeset viewer.